NYTimes Connections
- ScottFromWyoming - May 7, 2024 - 11:04am
Israel
- R_P - May 7, 2024 - 10:54am
Name My Band
- oldviolin - May 7, 2024 - 10:40am
Trump
- kurtster - May 7, 2024 - 10:08am
What the hell OV?
- oldviolin - May 7, 2024 - 9:40am
Song of the Day
- oldviolin - May 7, 2024 - 9:21am
Vinyl Only Spin List
- kurtster - May 7, 2024 - 9:14am
NY Times Strands
- Bill_J - May 7, 2024 - 9:08am
Things You Thought Today
- NoEnzLefttoSplit - May 7, 2024 - 8:43am
Wordle - daily game
- geoff_morphini - May 7, 2024 - 8:11am
Radio Paradise Comments
- GeneP59 - May 7, 2024 - 6:25am
Today in History
- Red_Dragon - May 7, 2024 - 5:34am
Reviews and Pix from your concerts and shows you couldn't...
- Coaxial - May 7, 2024 - 4:34am
Russia
- R_P - May 7, 2024 - 1:59am
• • • The Once-a-Day • • •
- oldviolin - May 6, 2024 - 10:06pm
May 2024 Photo Theme - Peaceful
- Alchemist - May 6, 2024 - 9:18pm
Mixtape Culture Club
- KurtfromLaQuinta - May 6, 2024 - 8:51pm
Farts!
- KurtfromLaQuinta - May 6, 2024 - 8:44pm
Dialing 1-800-Manbird
- Isabeau - May 6, 2024 - 5:03pm
Joe Biden
- Isabeau - May 6, 2024 - 4:59pm
Politically Uncorrect News
- oldviolin - May 6, 2024 - 2:15pm
What can you hear right now?
- maryte - May 6, 2024 - 2:01pm
Other Medical Stuff
- kurtster - May 6, 2024 - 1:04pm
Rock Mix not up to same audio quality as Main and Mellow?
- rp567 - May 6, 2024 - 12:06pm
Music Requests
- black321 - May 6, 2024 - 11:57am
NASA & other news from space
- NoEnzLefttoSplit - May 6, 2024 - 11:37am
USA! USA! USA!
- R_P - May 6, 2024 - 9:52am
Global Warming
- NoEnzLefttoSplit - May 6, 2024 - 9:29am
Tales from the RAFT
- NoEnzLefttoSplit - May 6, 2024 - 9:19am
Food
- DaveInSaoMiguel - May 6, 2024 - 4:17am
What Did You See Today?
- KurtfromLaQuinta - May 5, 2024 - 5:28pm
Bug Reports & Feature Requests
- thisbody - May 5, 2024 - 4:38pm
The Abortion Wars
- thisbody - May 5, 2024 - 3:27pm
Those Lovable Policemen
- R_P - May 5, 2024 - 3:12pm
The Obituary Page
- Red_Dragon - May 5, 2024 - 2:53pm
Ukraine
- thisbody - May 5, 2024 - 12:33pm
What Are You Going To Do Today?
- GeneP59 - May 5, 2024 - 12:07pm
volcano!
- geoff_morphini - May 5, 2024 - 9:55am
Tesla (motors, batteries, etc)
- miamizsun - May 5, 2024 - 6:16am
Favorite Quotes
- Isabeau - May 4, 2024 - 5:21pm
Anti-War
- R_P - May 4, 2024 - 3:24pm
Iran
- Red_Dragon - May 4, 2024 - 12:03pm
Live Music
- oldviolin - May 4, 2024 - 11:18am
SCOTUS
- Steely_D - May 4, 2024 - 8:04am
The Dragons' Roost
- GeneP59 - May 3, 2024 - 3:53pm
RightWingNutZ
- islander - May 3, 2024 - 11:55am
Photography Forum - Your Own Photos
- MrDill - May 3, 2024 - 11:41am
Poetry Forum
- oldviolin - May 3, 2024 - 9:46am
Lyrics that strike a chord today...
- R_P - May 3, 2024 - 7:54am
Derplahoma!
- sunybuny - May 3, 2024 - 4:56am
Unquiet Minds - Mental Health Forum
- miamizsun - May 3, 2024 - 4:36am
What Makes You Laugh?
- miamizsun - May 3, 2024 - 4:31am
Main Mix Playlist
- R567 - May 3, 2024 - 12:06am
Who Killed The Electric Car??? -- The Movie
- KurtfromLaQuinta - May 2, 2024 - 9:51pm
If not RP, what are you listening to right now?
- oldviolin - May 2, 2024 - 5:56pm
What Makes You Sad?
- thisbody - May 2, 2024 - 3:35pm
songs that ROCK!
- thisbody - May 2, 2024 - 3:07pm
Breaking News
- thisbody - May 2, 2024 - 2:57pm
Questions.
- oldviolin - May 2, 2024 - 9:13am
And the good news is....
- Bill_J - May 1, 2024 - 6:30pm
Things you would be grating food for
- Manbird - May 1, 2024 - 3:58pm
Economix
- black321 - May 1, 2024 - 12:19pm
I Heart Huckabee - NOT!
- Manbird - Apr 30, 2024 - 7:49pm
Democratic Party
- R_P - Apr 30, 2024 - 4:01pm
Oh, The Stupidity
- haresfur - Apr 30, 2024 - 3:30pm
Talk Behind Their Backs Forum
- VV - Apr 30, 2024 - 1:46pm
Canada
- black321 - Apr 30, 2024 - 1:37pm
New Music
- ScottFromWyoming - Apr 29, 2024 - 11:36am
Upcoming concerts or shows you can't wait to see
- ScottFromWyoming - Apr 29, 2024 - 8:34am
Photos you haven't taken of yourself
- Antigone - Apr 29, 2024 - 5:03am
Britain
- R_P - Apr 28, 2024 - 10:47am
Birthday wishes
- GeneP59 - Apr 28, 2024 - 9:56am
Would you drive this car for dating with ur girl?
- KurtfromLaQuinta - Apr 27, 2024 - 9:53pm
Classical Music
- miamizsun - Apr 27, 2024 - 1:23pm
LeftWingNutZ
- Lazy8 - Apr 27, 2024 - 12:46pm
|
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
}
|
|
|