Start internet radio on Apple Music

I’d like an apple script to start playing an internet radio station on Apple Music (Big Sur)

For example, I’d like to play the station CBC Radio One. I can find the URL through apple music, and try to open it

tell application “Music”
open location “https://music.apple.com/ca/station/cbc-radio-one/ra.1388704969
end tell

but this does not work.

Any direction would be appreciated.

Thanks!

Not sure, but I think Music.app works with payed radio stations, listed in the iTunes Store. If you want listen you concrete free radio station for free, forgot the Music.app and use the browser instead:


tell application "Safari"
	activate
	open location "https://www.cbc.ca/listen/live-radio"
	my waitSafariWebPageLoading()
	do JavaScript "document.getElementsByClassName('playButton hero large no-border')[0].click();" in document 1
end tell

on waitSafariWebPageLoading()
	tell application "System Events" to tell application process "Safari"
		repeat until (UI element "Reload this page" of group 3 of toolbar 1 of window 1 exists) or (UI element "Reload this page" of group 2 of toolbar 1 of window 1 exists)
			delay 0.1
		end repeat
	end tell
end waitSafariWebPageLoading

You can use safari to open the link:

https://music.apple.com/ca/station/cbc-radio-one/ra.1388704969

The music.apple.com will make Safari ask if you would like to open it in Music App

The Music app has registered that URI.

Which might be why music doesn’t open it.
Things to try:

  • remove the music.apple.com part
  • try making a URL from the link
  • Check the Dictionary for info on opening streams