Wordle - daily game
- kurtster - May 16, 2022 - 9:15pm
Help Finding A Song
- Tom_L - May 16, 2022 - 8:46pm
Vinyl Only Spin List
- kurtster - May 16, 2022 - 8:44pm
"2000 Mules" movie purports to prove 2020 election was st...
- Steely_D - May 16, 2022 - 7:33pm
Buddy's Haven
- oldviolin - May 16, 2022 - 6:31pm
Photography Forum - Your Own Photos
- Alchemist - May 16, 2022 - 6:25pm
• • • The Once-a-Day • • •
- oldviolin - May 16, 2022 - 6:18pm
Environment
- Red_Dragon - May 16, 2022 - 4:42pm
RightWingNutZ
- Red_Dragon - May 16, 2022 - 4:24pm
260,000 Posts in one thread?
- oldviolin - May 16, 2022 - 3:24pm
Ukraine
- Red_Dragon - May 16, 2022 - 2:52pm
New Music
- miamizsun - May 16, 2022 - 12:37pm
• • • Clownstock • • •
- oldviolin - May 16, 2022 - 10:17am
What is the meaning of this?
- oldviolin - May 16, 2022 - 10:08am
What the hell OV?
- miamizsun - May 16, 2022 - 9:40am
What Did You Do Today?
- miamizsun - May 16, 2022 - 9:37am
Supreme Court Rulings
- Red_Dragon - May 16, 2022 - 9:33am
Trump
- rgio - May 16, 2022 - 8:51am
Outstanding Covers
- oldviolin - May 16, 2022 - 8:35am
Talk Behind Their Backs Forum
- oldviolin - May 16, 2022 - 7:13am
Name My Band
- oldviolin - May 16, 2022 - 6:26am
Radio Paradise Comments
- oldviolin - May 16, 2022 - 6:12am
Watching My Mind Slip Away...
- oldviolin - May 16, 2022 - 6:05am
Mixtape Culture Club
- miamizsun - May 16, 2022 - 4:22am
Reccomended System or Powered Speakers
- miamizsun - May 16, 2022 - 3:45am
Great Old Songs You Rarely Hear Anymore
- Alchemist - May 15, 2022 - 10:12pm
TuneIn difficulties
- KurtfromLaQuinta - May 15, 2022 - 7:02pm
Terrorist Watch!
- Steely_D - May 15, 2022 - 5:17pm
Climate Change
- Red_Dragon - May 15, 2022 - 1:31pm
Spain
- Red_Dragon - May 15, 2022 - 11:04am
Get Your Godcast!
- Red_Dragon - May 14, 2022 - 4:52pm
TV shows you watch
- Red_Dragon - May 14, 2022 - 4:03pm
Republican Party
- rgio - May 14, 2022 - 3:15pm
The Abortion Wars
- Red_Dragon - May 14, 2022 - 2:20pm
Guns
- Red_Dragon - May 14, 2022 - 2:08pm
Finland
- Red_Dragon - May 14, 2022 - 11:28am
CRAZY Flooding Video!
- Red_Dragon - May 14, 2022 - 7:35am
Today in History
- Red_Dragon - May 14, 2022 - 7:00am
Bluesound MQA stream not working for me
- Juancastilo - May 14, 2022 - 6:48am
Australia has Disappeared
- Red_Dragon - May 14, 2022 - 6:07am
The Obituary Page
- KurtfromLaQuinta - May 13, 2022 - 8:35pm
Gotta Get Your Drink On
- Antigone - May 13, 2022 - 5:25pm
Counting with Pictures
- nightdrive - May 13, 2022 - 2:10pm
Bad Poetry
- oldviolin - May 13, 2022 - 8:04am
The Dragons' Roost
- GeneP59 - May 13, 2022 - 7:15am
Women in the World
- miamizsun - May 13, 2022 - 6:21am
2020 Elections
- Red_Dragon - May 12, 2022 - 12:34pm
NASA & other news from space
- GeneP59 - May 12, 2022 - 8:09am
George Carlin
- GeneP59 - May 12, 2022 - 7:35am
Stuff I've Said Out Loud
- GeneP59 - May 12, 2022 - 7:25am
Flower Pictures
- Proclivities - May 12, 2022 - 6:29am
What Did You See Today?
- KurtfromLaQuinta - May 12, 2022 - 5:47am
COVID-19
- miamizsun - May 12, 2022 - 4:48am
Russia
- miamizsun - May 12, 2022 - 4:36am
A motivational quote
- Proclivities - May 11, 2022 - 2:01pm
Dialing 1-800-Manbird
- miamizsun - May 11, 2022 - 5:58am
Positive Thoughts and Prayer Requests
- Antigone - May 11, 2022 - 5:36am
Whatever happened to Taco Wagon?
- miamizsun - May 11, 2022 - 4:13am
Pernicious Pious Proclivities Particularized Prodigiously
- haresfur - May 11, 2022 - 2:05am
Things You Thought Today
- Red_Dragon - May 10, 2022 - 7:39pm
Delicacies: a..k.a.. the Gross Food forum
- miamizsun - May 10, 2022 - 2:42pm
Back to the 60's
- R_P - May 10, 2022 - 1:34pm
do you Twitter?
- Red_Dragon - May 10, 2022 - 12:52pm
My nickname
- miamizsun - May 10, 2022 - 10:28am
DQ (as in 'Daily Quote')
- Proclivities - May 9, 2022 - 1:58pm
Paul McCartney
- Steely_D - May 9, 2022 - 12:42pm
FLAC Streaming
- BillG - May 9, 2022 - 8:00am
RP Cryptocurrency support
- reneng - May 8, 2022 - 8:49am
Mother's Day
- miamizsun - May 8, 2022 - 6:02am
Don't Make Me Laugh
- KurtfromLaQuinta - May 7, 2022 - 11:34am
Poetry Forum
- Antigone - May 7, 2022 - 7:11am
Those Lovable Policemen
- Red_Dragon - May 6, 2022 - 5:43am
Free Speech?
- rgio - May 6, 2022 - 4:11am
Hockey + Fantasy Hockey
- GeneP59 - May 5, 2022 - 3:56pm
Amazon Products (May Contain Spam)
- Red_Dragon - May 5, 2022 - 2:26pm
|
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
}
|
|
|