shin1m / alexaagent

Alexa Voice Service Agent
5 stars 4 forks source link

doesn't support playlist URL #4

Open RogerLaw opened 8 years ago

RogerLaw commented 8 years ago

When asked for tune-in stations, it will return a URL with content-type of "audio/x-mpegurl", then ffmpeg will fail to play it.

Also, it won't recover from this status. the AudioPlayer.PlaybackFailed event got a 200 response with new directive to play the same URL, repeated again and again, which I think might be a problem of alexa api.

sometimes, I got a segmentation fault with this.

Reproduce with "play economist radio on tune-in", then we got a url: "http://opml.radiotime.com/Tune.ashx?id=s223220&formats=aac,mp3&partnerId=4JqugguZ&serial=AFPFRQBP3Y34KMJYVH6JHY4YL3UA&latlon=47.631863,-122.34427" and this URL will return a playlist content.

shin1m commented 8 years ago

Thank you for the report. I will investigate it. Best regards,

shin1m commented 8 years ago

After struggling with several candidate solutions, I added a hook to handle x-mpegurl on PlaybackFailed although it is a kind of tentative hack.

As you mention, it seems ffmpeg does not handle x-mpegurl.

And I think repeating the same url on failure might be the behavior of TuneIn skill according to this post.

Best regards,

RogerLaw commented 8 years ago

Cool! I just tried and this override works. "play economist radio on tune-in" is OK.

The tunein is really troublesome, since I just found many other urls will return with a playlist file. for example, "play BBC radio 1 by tune-in", we got an link like: http://opml.radiotime.com/Tune.ashx?id=s24939&formats=aac,mp3&partnerId=4JqugguZ&serial=AFPFRQBP3Y34KMJYVH6JHY4YL3UA&latlon=47.631863,-122.34427

this will lead to another URL, which is still not playable: http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-mp3-a/vpid/bbc_radio_one/format/pls.pls

this playlist URL returns 2 URLs playlist: [playlist] NumberOfEntries=2 File1=http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1474297464&e=1474311864&h=a2e2834f346424584d5736c0837dbbb7 Title1=No Title Length1=-1 File2=http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q?s=1474297464&e=1474311864&h=4791c2a709695596bcfdaef63fd6747e Title2=No Title Length2=-1

RogerLaw commented 8 years ago

another possibility, is getting x-mpegurl again:

one more possibility:


I added some codes to retry URL in contents returned. now it works. Also I suggest trim the string "retry" before open it, since it may contain \r or spaces.

BTW. ./tiny_http "http://kuow.streamguys1.com/kuow1-hi.mp3.m3u" here, ~t_http will cause SIGSEGV

shin1m commented 8 years ago

Thank you for the investigation. I've just pushed further support for playlists.

Regarding tiny_http test executable, maybe it occurs when boost::asio::read* is called without error_code argument and it reaches eof. I modified the code to call it with error_code.

Regarding x-scpls, I chose converting it to a pseudo HLS playlist to utilize HLS feature of ffmpeg. I hope any other informal playlists can be supported using the same approach.

Addition to that, I changed the behavior on failure to sending PlaybackStopped instead of sending PlaybackFailed.

Best regards.