Extension of REST api to support HTML5 audio playback

Got an idea? Missing something? Post your feature request here.

Moderator: moderators

Extension of REST api to support HTML5 audio playback

Postby peter123 » Fri Jan 29, 2010 8:24 am

Hi,

I'm exploring the use of the HTML5 audio element to play back music from my Subsonic server using the REST api.

It turns out, as far as I can tell, that the audio element is quite picky with regards to the URL it is fed. If I use either the URL from the "stream" or "download" rest query the audio element is unable to interpret the URL. My suspicion is that it looks at URL file extension such as mp3 (something the rest api does not provide). I have verified the URL to be valid so that is not the issue!

So to my questions/request.

Would it be possible to extend the REST api to somehow provide a way to support use of HTML5 audio? It might work by providing a REST api which includes the file name extension (such as the Flickr API, http://www.flickr.com/services/api/misc.urls.html )

Thanks,
P
peter123
 
Posts: 8
Joined: Fri Jan 29, 2010 8:06 am

Postby sindre_mehus » Fri Jan 29, 2010 9:54 am

Hi,

The suffix (and transcodedSuffix) are returned in the xml so you could just append it to the stream url:

Code: Select all
http://your-server/rest/stream.view?id=42&suffix=.mp3


Please let us know how the html5 thing goes :-)

Sindre
Subsonic developer
User avatar
sindre_mehus
 
Posts: 1955
Joined: Tue Nov 29, 2005 6:19 pm
Location: Oslo, Norway

Postby peter123 » Fri Jan 29, 2010 4:37 pm

Hi Sindre,

thanks for the feedback on suffix.

Sorry, I should have been more clear in my original email. I am using suffix ".mp3" but the HTML5 audio element fails to load the audio track. I encounter the same scenario in Chrome, Firefox and Safari.

For instance: The below static audio element with subsonic reference(replace with existing url) does not work:
<audio id="staticaudio" src="http://<server>/rest/stream.view?u=xxx&p=xxxx&v=1.1.0&c=ipsubapp&id=1234&suffix=.mp3" controls="">Browser does not support Audio tag</audio>

While the below construct using a direct url to a mp3 works fine:
<audio id="staticaudio" src="test.mp3" controls="">Browser does not support Audio tag</audio>


BTW. Sindre: Thanks for your awesome work on Subsonic!

Thanks,
Petter
peter123
 
Posts: 8
Joined: Fri Jan 29, 2010 8:06 am

Postby peter123 » Thu Feb 04, 2010 4:50 am

Hi again,

Has anyone else on this forum been successful in using the HTML 5 Audio element with the Subsonic REST API?

Thanks,
Petter
peter123
 
Posts: 8
Joined: Fri Jan 29, 2010 8:06 am

Postby hansolos » Thu Feb 04, 2010 5:12 pm

I was thinking about that the other day, plug-in free audio playback. Since it seems like companies like Apple are out to kill Flash anyway. It would be great to be able to fully use SubSonic on the iPhone. I've found a few examples of HTML5 that work in mobile safari (as examples not in SubSonic). I've also read that Firefox does not support MP3, only OGG or WAV just fyi.
hansolos
 
Posts: 11
Joined: Thu Feb 04, 2010 5:00 pm

Postby peter123 » Sat Feb 06, 2010 4:24 pm

Hi hansolos.

Yes, that is one of the ideas I have using HTML5 with Subsonic.

HTML5 audio tags work fine in Mobile Safari, albeit with some limitations. Just feeding it an URL to mp3 file works fine. But, for some reason the Subsonic REST DL or Stream response is not understood as an URL by the audio element.

If someone has any ideas on how to hack this or how Subsonic could be modified to support this use case, that would be awesome.

Thanks,
Petter
peter123
 
Posts: 8
Joined: Fri Jan 29, 2010 8:06 am

Postby reddragon72 » Thu Mar 11, 2010 9:31 pm

I am trying to figure out how to use HTML5 to do the video transcoding side of Subsonic. Right now I am using an Android phone and as we know there is no flash for it, plus I don't think I want flash for on it at all. So my idea has been to try and use the subsonic site and replace the flash player with a html5 player and get my videos to stream in mp4(h264) to my phone. I'm going to crate a test bed to start ripping this apart and replace the flash player with one of the many available HTML5 players out there. but please don't wait for me to do all of this keep working at it cause I am very unfamiliar with all of this, but I am quick to learn.
reddragon72
 
Posts: 18
Joined: Sat Sep 19, 2009 5:29 pm

Postby peter123 » Mon Mar 15, 2010 6:18 am

Hi,

I have not looked at this issue for quite awhile. I still suspect the issue is related to the way the HTML Audio element (same for all HTML5 ready browsers) interprets and handles content URLs. I'm out of ideas. But I believe the issue could probably be fixed by somehow modifying the response that Subsonic delivered via REST Stream or Download API.

It is possible that you will run into the same issue I have when trying to address video. If you somehow make it work I'm very interested in hearing your solution.

Sindre, would it be possible for you to look into this? Enabling Subsonic access via HTML5 media elements could potentially open up lots of interesting innovation.

/Petter
peter123
 
Posts: 8
Joined: Fri Jan 29, 2010 8:06 am

Postby lavamind » Sun Mar 21, 2010 2:19 am

HTML5 support would definately be a huge feature for Subsonic, especially for users like me that have a collection mostly encoded using OGG.

Using HTML5 could also have the potential of removing the need to transcoding on the server, since decoding is done at the browser level.
lavamind
 
Posts: 6
Joined: Sun Sep 27, 2009 11:45 pm

Postby merlow » Fri Apr 16, 2010 5:42 pm

HTML5 support would be great. Perhaps it has something to do with the stream not returning the file size.

If I go to the stream.view link in Chrome it will show the player but will not play anything. If I create a file mp3.php and use the code

Code: Select all
header('Content-type: audio/mpeg');
header('content-length: <song file size>');
header('accept-ranges: bytes');
header('Cache-Control: max-age=0');
header('etag: <subsonic song id>');

$track = "<subsonic server>/rest/stream.view?u=<username>&p=<password>&v=1.1.0&c=myapp&id=<song id>&suffix=.mp3";
readfile($track);
exit;


If I go to mp3.php in Chrome or Safari it plays exactly how it is supposed to. It also will then work with the <audio> tag. The only difference that I can see is that I am sending the content-length header and stream.view is not.

How can I change this in my subsonic installation to test it?

Thanks
merlow
 
Posts: 2
Joined: Fri Apr 16, 2010 5:29 pm

Postby zsiegel87 » Fri Jun 11, 2010 3:37 am

Hey everyone great to see other people are interested in this as well.

I am almost certain that its because of the headers. The PHP script merlow wrote works great and I am currently trying to use that as a generic wrapper for the html5 audio tag. I will update you guys on my progress as i am trying to get a basic playlist/player up and running with the randomSongs REST call.

Ideally we may be able to modify the API to fix the headers to give us a proper stream but in the meantime i think its possible for this to work with the PHP hack provided by merlow!
zsiegel87
 
Posts: 1
Joined: Fri Jun 11, 2010 3:33 am

Postby the_slain_man » Mon Jun 14, 2010 9:46 am

Was going to make a feature request for this but found this already, nice.
This feature will be very appreciated by me and other linux/unix (windows users to) user so we dont have to use the flash blob.
Thou if firefox dont support mp3 its kinda disappointing and troublesome for people with mp3 collection.
the_slain_man
 
Posts: 10
Joined: Sun May 23, 2010 8:22 pm

Postby brett » Wed Jul 21, 2010 12:02 am

I'd like to bump a request for content-length headers to be sent in the stream.view, I put in a request at longtailvideo(makers of jwplayer) to not require them, but until they fix it the 5.2 player doesn't report any time position because the content-length headers aren't supplied.


Thanks,
brett
brett
 
Posts: 55
Joined: Thu Jun 10, 2010 7:13 am

Postby honeycrippen12 » Sat Aug 28, 2010 8:11 am

I've been using subsonic for a few weeks to stream my flac collection but I'm not happy with the short skips when caching songs.

Is anybody else getting skips on 2.1?





Thanks
Honey
_______________
magic mic karaoke
honeycrippen12
 
Posts: 1
Joined: Sat Aug 28, 2010 7:54 am

Postby nigeltrash » Sat Sep 04, 2010 5:47 pm

I noted in the release notes for the most recent beta that "Bugfix: Support html5 (return correct content type and length)." I am still having a problem getting the stream to work with the HTML5 audio tag. Anybody having any luck with this. Here is the format I have been trying:

<audio id="staticaudio" src="http://10.0.0.3:8888/rest/stream.view?id=songidhere&u=admin&p=password&v=1.3.0&c=myapp&suffix=.mp3" controls>No Support</audio>


This just doesn't seem to want to work. Anybody having any luck?
nigeltrash
 
Posts: 2
Joined: Sat Sep 04, 2010 5:42 pm

Next

Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests