Israel
- R_P - Apr 26, 2024 - 12:15pm
Breaking News
- kcar - Apr 26, 2024 - 11:17am
Radio Paradise sounding better recently
- firefly6 - Apr 26, 2024 - 10:39am
Neil Young
- Steely_D - Apr 26, 2024 - 9:20am
NY Times Strands
- geoff_morphini - Apr 26, 2024 - 9:20am
NYTimes Connections
- geoff_morphini - Apr 26, 2024 - 9:08am
Wordle - daily game
- geoff_morphini - Apr 26, 2024 - 9:02am
SCOTUS
- Red_Dragon - Apr 26, 2024 - 9:01am
Country Up The Bumpkin
- KurtfromLaQuinta - Apr 26, 2024 - 9:01am
Australia has Disappeared
- Red_Dragon - Apr 26, 2024 - 6:39am
Today in History
- Red_Dragon - Apr 26, 2024 - 6:03am
Radio Paradise Comments
- miamizsun - Apr 26, 2024 - 5:09am
Environmental, Brilliance or Stupidity
- miamizsun - Apr 26, 2024 - 5:07am
The Obituary Page
- DaveInSaoMiguel - Apr 26, 2024 - 3:47am
Trump
- kcar - Apr 25, 2024 - 10:53pm
Joe Biden
- kurtster - Apr 25, 2024 - 9:24pm
Talk Behind Their Backs Forum
- islander - Apr 25, 2024 - 2:28pm
Things You Thought Today
- Manbird - Apr 25, 2024 - 2:12pm
Poetry Forum
- Manbird - Apr 25, 2024 - 12:30pm
Ask an Atheist
- R_P - Apr 25, 2024 - 11:02am
Mixtape Culture Club
- miamizsun - Apr 25, 2024 - 10:36am
Afghanistan
- R_P - Apr 25, 2024 - 10:26am
Science in the News
- Red_Dragon - Apr 25, 2024 - 10:00am
What the hell OV?
- miamizsun - Apr 25, 2024 - 9:46am
The Abortion Wars
- Isabeau - Apr 25, 2024 - 9:27am
Photography Forum - Your Own Photos
- Proclivities - Apr 25, 2024 - 7:33am
Vinyl Only Spin List
- ColdMiser - Apr 25, 2024 - 7:15am
What's that smell?
- Manbird - Apr 24, 2024 - 10:27pm
Song of the Day
- oldviolin - Apr 24, 2024 - 10:20pm
April 2024 Photo Theme - Happenstance
- oldviolin - Apr 24, 2024 - 9:50pm
260,000 Posts in one thread?
- NoEnzLefttoSplit - Apr 24, 2024 - 10:55am
Would you drive this car for dating with ur girl?
- rgio - Apr 24, 2024 - 8:44am
TV shows you watch
- Beaker - Apr 24, 2024 - 7:32am
The Moon
- haresfur - Apr 23, 2024 - 9:29pm
Dialing 1-800-Manbird
- Bill_J - Apr 23, 2024 - 7:15pm
China
- R_P - Apr 23, 2024 - 5:35pm
Economix
- islander - Apr 23, 2024 - 12:11pm
USA! USA! USA!
- R_P - Apr 23, 2024 - 11:05am
One Partying State - Wyoming News
- sunybuny - Apr 23, 2024 - 6:53am
YouTube: Music-Videos
- Red_Dragon - Apr 22, 2024 - 7:42pm
Ukraine
- haresfur - Apr 22, 2024 - 6:19pm
songs that ROCK!
- Steely_D - Apr 22, 2024 - 1:50pm
Bug Reports & Feature Requests
- q4Fry - Apr 22, 2024 - 11:57am
Republican Party
- R_P - Apr 22, 2024 - 9:36am
Mini Meetups - Post Here!
- ScottFromWyoming - Apr 22, 2024 - 8:59am
Malaysia
- dcruzj - Apr 22, 2024 - 7:30am
Canada
- westslope - Apr 22, 2024 - 6:23am
Russia
- NoEnzLefttoSplit - Apr 22, 2024 - 1:03am
Broccoli for cats - you gotta see this!
- Bill_J - Apr 21, 2024 - 6:16pm
Name My Band
- DaveInSaoMiguel - Apr 21, 2024 - 3:06pm
Main Mix Playlist
- thisbody - Apr 21, 2024 - 12:04pm
George Orwell
- oldviolin - Apr 21, 2024 - 11:36am
• • • The Once-a-Day • • •
- oldviolin - Apr 20, 2024 - 7:44pm
What Did You See Today?
- Welly - Apr 20, 2024 - 4:50pm
Radio Paradise on multiple Echo speakers via an Alexa Rou...
- victory806 - Apr 20, 2024 - 2:11pm
Libertarian Party
- R_P - Apr 20, 2024 - 11:18am
Remembering the Good Old Days
- kurtster - Apr 20, 2024 - 2:37am
Words I didn't know...yrs ago
- Bill_J - Apr 19, 2024 - 7:06pm
Things that make you go Hmmmm.....
- Bill_J - Apr 19, 2024 - 6:59pm
Baseball, anyone?
- Red_Dragon - Apr 19, 2024 - 6:51pm
MILESTONES: Famous People, Dead Today, Born Today, Etc.
- Bill_J - Apr 19, 2024 - 6:44pm
2024 Elections!
- steeler - Apr 19, 2024 - 5:49pm
how do you feel right now?
- miamizsun - Apr 19, 2024 - 6:02am
When I need a Laugh I ...
- miamizsun - Apr 19, 2024 - 5:43am
Live Music
- oldviolin - Apr 18, 2024 - 3:24pm
What Makes You Laugh?
- oldviolin - Apr 18, 2024 - 2:49pm
Robots
- miamizsun - Apr 18, 2024 - 2:18pm
Museum Of Bad Album Covers
- Steve - Apr 18, 2024 - 6:58am
Europe
- haresfur - Apr 17, 2024 - 6:47pm
Business as Usual
- black321 - Apr 17, 2024 - 1:48pm
Magic Eye optical Illusions
- Proclivities - Apr 17, 2024 - 10:08am
Just for the Haiku of it. . .
- oldviolin - Apr 17, 2024 - 9:01am
HALF A WORLD
- oldviolin - Apr 17, 2024 - 8:52am
Little known information... maybe even facts
- R_P - Apr 16, 2024 - 3:29pm
WTF??!!
- rgio - Apr 16, 2024 - 5:23am
|
Index »
Radio Paradise/General »
General Discussion »
RP Now Playing Widget for iOS
|
Page: |
Diamar
Location: Orcas Island, WA Gender:
|
Posted:
Jan 27, 2022 - 12:14pm |
|
Iâve been using Scriptable to display a âNow Playingâ widget for RP on iOS. I cobbled it together from some random code bits I picked up from the web, then customized it. It lets you see the album covers and song title/artist for the currently playing song on any RP channel.
To use it: - Install the Scriptable app on your iOS device if itâs not there already
- Launch the Scriptable app, then create and save a new script using the code at the end of this post
- Create a new widget (or widget stack) on your iOS device, choosing âScriptableâ as the type and any of the Run Script widgets it can make
- Specify the newly-made script from step 2 above, adding the parameter for the channel youâd like the widget to display (main, mellow, rock, world). If you donât add a parameter, âmainâ will default
If you put 4 calls to your widget in a widget stack, you can just scroll through all the channels and see covers.
The only thing I canât control is how quickly the screen updates, since iOS doesnât apparently let you have too much control over that. But itâll always refresh if you tap it (but it launches the Scriptable app to show it).
Hereâs the code:
let stationName = "main"
let stationID = 0
stationId = getConfiguredStationId()
let nowPlaying = await loadNowPlaying(stationId)
let widget = await createWidget(nowPlaying, stationName)
if (config.runsInWidget) {
Script.setWidget(widget)
Script.complete()
} else await widget.presentLarge()
async function createWidget(nowPlaying,stationName) {
let widget = new ListWidget()
widget.setPadding(8, 10, 12, 10)
// set gradient background with transparency
let gradient = new LinearGradient()
gradient.colors =
gradient.locations = <0.0, 1>
widget.backgroundGradient = gradient
widget.backgroundColor = new Color("#1c1c1c")
// load image
let coverArt = await loadImage(nowPlaying.cover)
widget.backgroundImage = coverArt
//Set refresh time unless this song is almost over
//Only mess with this if we have more than "enough" seconds left
const enough = 4
if (nowPlaying.time > enough) {
const n = new Date(Date.now())
widget.refreshAfterDate = new Date((Number(n) + 1000 * Math.max(1, nowPlaying.time-enough)))
} else widget.refreshAfterDate = null
widget.addSpacer()
//add channel
let channelTxt = widget.addText("RP " + stationName)
channelTxt.font = Font.semiboldRoundedSystemFont(12)
channelTxt.textColor = Color.red()
// add title and artist
let titleTxt = widget.addText(nowPlaying.title)
titleTxt.font = Font.boldRoundedSystemFont(15)
titleTxt.textColor = Color.white()
widget.addSpacer(2)
let artistTxt = widget.addText(nowPlaying.artist)
artistTxt.font = Font.boldRoundedSystemFont(14)
artistTxt.textColor = Color.yellow()
//widget.url = "vlc-x-callback://x-callback-url/stream?url=https://stream.radioparadise.com/" + stationName
return widget
}
// verify the configured flac stream
function getConfiguredStationId() {
let param = args.widgetParameter
let stationID
//if(param != null) {
switch (param) {
case 'main':
stationId = 0
stationName = "Main"
break
case 'mellow':
stationId = 1
stationName = "Mellow"
break
case 'rock':
stationId = 2
stationName = "Rock"
break
case 'world':
stationId = 3
stationName = "World"
break
default:
stationId = 0
stationName = "Main"
}
return stationId
}
// helper function to load and parse a restful json api
async function loadNowPlaying(stationId) {
const url = "https://api.radioparadise.com/api/now_playing?chan=" + stationId
let req = new Request(url)
let json = await req.loadJSON()
return json
}
// helper function to download an image from a given url
async function loadImage(imgUrl) {
let req = new Request(imgUrl)
let image = await req.loadImage()
return image
}
|
|
|