Wordle - daily game
- geoff_morphini - May 21, 2022 - 8:00am
Trump
- Lazy8 - May 21, 2022 - 7:05am
Today, I learned...
- Proclivities - May 21, 2022 - 7:02am
Things You Thought Today
- Antigone - May 21, 2022 - 5:05am
MQA Stream Coming to BLUOS
- nickt1 - May 21, 2022 - 1:09am
Live Music
- oldviolin - May 20, 2022 - 7:06pm
Favorite Quotes
- Bill_J - May 20, 2022 - 7:05pm
What is the meaning of this?
- oldviolin - May 20, 2022 - 7:04pm
Neil Young
- oldviolin - May 20, 2022 - 6:50pm
songs for drella
- haresfur - May 20, 2022 - 5:47pm
Chicago 25 Or 6 To 4
- Steely_D - May 20, 2022 - 2:42pm
Reccomended System or Powered Speakers
- KurtfromLaQuinta - May 20, 2022 - 7:04am
Dialing 1-800-Manbird
- miamizsun - May 20, 2022 - 6:50am
Radio Paradise Comments
- miamizsun - May 20, 2022 - 6:48am
Counting with Pictures
- darkblue - May 20, 2022 - 6:21am
Today in History
- Red_Dragon - May 20, 2022 - 6:05am
Derplahoma!
- sunybuny - May 20, 2022 - 5:41am
Unquiet Minds - Mental Health Forum
- miamizsun - May 20, 2022 - 5:16am
The Obituary Page
- thisbody - May 19, 2022 - 10:01pm
Name My Band
- haresfur - May 19, 2022 - 8:10pm
songs that ROCK!
- Red_Dragon - May 19, 2022 - 5:10pm
Online Radio Platforms
- Steely_D - May 19, 2022 - 4:03pm
Brag about your stereo
- miamizsun - May 19, 2022 - 3:16pm
All Dogs Go To Heaven - Dog Pix
- islander - May 19, 2022 - 3:00pm
COVID-19
- Red_Dragon - May 19, 2022 - 1:50pm
Testing your Metal?
- oldviolin - May 19, 2022 - 12:11pm
Ukraine
- NoEnzLefttoSplit - May 19, 2022 - 10:37am
Help Finding A Song
- nightdrive - May 19, 2022 - 10:19am
Lyrics
- oldviolin - May 19, 2022 - 8:17am
What Did You Do Today?
- miamizsun - May 19, 2022 - 4:08am
New Song Submissions system
- danielh - May 19, 2022 - 2:09am
What Makes You Sad?
- Coaxial - May 18, 2022 - 6:42pm
NASA & other news from space
- GeneP59 - May 18, 2022 - 4:37pm
Talk Behind Their Backs Forum
- GeneP59 - May 18, 2022 - 4:12pm
Guided Meditation by Bill
- thisbody - May 18, 2022 - 2:45pm
January 20th, 2005 ~ Boycott And Meditation Day
- thisbody - May 18, 2022 - 2:34pm
Mixtape Culture Club
- miamizsun - May 18, 2022 - 1:55pm
Economix
- thisbody - May 18, 2022 - 1:48pm
Japan
- Red_Dragon - May 18, 2022 - 10:58am
Race in America
- Red_Dragon - May 18, 2022 - 7:36am
North Korea
- Red_Dragon - May 17, 2022 - 9:07pm
Photography Forum - Your Own Photos
- KurtfromLaQuinta - May 17, 2022 - 11:24am
"2000 Mules" movie purports to prove 2020 election was st...
- rgio - May 17, 2022 - 7:02am
Vinyl Only Spin List
- kurtster - May 16, 2022 - 8:44pm
Buddy's Haven
- oldviolin - May 16, 2022 - 6:31pm
• • • 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
New Music
- miamizsun - May 16, 2022 - 12:37pm
• • • Clownstock • • •
- oldviolin - May 16, 2022 - 10:17am
What the hell OV?
- miamizsun - May 16, 2022 - 9:40am
Supreme Court Rulings
- Red_Dragon - May 16, 2022 - 9:33am
Outstanding Covers
- oldviolin - May 16, 2022 - 8:35am
Watching My Mind Slip Away...
- oldviolin - May 16, 2022 - 6:05am
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
Bluesound MQA stream not working for me
- Juancastilo - May 14, 2022 - 6:48am
Australia has Disappeared
- Red_Dragon - May 14, 2022 - 6:07am
Gotta Get Your Drink On
- Antigone - May 13, 2022 - 5:25pm
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
George Carlin
- GeneP59 - May 12, 2022 - 7:35am
Stuff I've Said Out Loud
- GeneP59 - May 12, 2022 - 7:25am
|
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
}
|
|
|