Extension of REST api to support HTML5 audio playback

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

Moderator: moderators

Postby sindre_mehus » Tue Sep 07, 2010 7:21 pm

I successfully tested something similar to this both in Opera and Firefox, so it should work.

What happens if you put that URL directly in the browser? Does it download the mp3 file, and does it show up-front the file size?
Subsonic developer
User avatar
sindre_mehus
 
Posts: 1955
Joined: Tue Nov 29, 2005 6:19 pm
Location: Oslo, Norway

Postby nigeltrash » Wed Sep 15, 2010 4:37 am

Sorry, didn't see your reply on the second page. Thanks for posting!

If I post the url (the string starting with http:// and ending with .mp3) it starts streaming the song in the quicktime player in a new tab of the firefox browser. If I use 'download.view' instead of 'stream.view', it opens up a download options box and will download the file to the directory of my choice. It doesn't list the file size up front, but it doesn't show it on other files I download. Could you post the code you have used to get the <audio> tag working inside an html file? Thanks again for the reply and the awesome program!!!!

p.s. -I know that secondary to licensing issues, mp3 is not supported as a file type in html5 in firefox, but it should be in Chrome, and when I try the code from my last post it doesn't work either....
nigeltrash
 
Posts: 2
Joined: Sat Sep 04, 2010 5:42 pm

Postby mattgoldspink » Sun Nov 14, 2010 4:51 pm

Has anyone made any headway on this yet? I'm really stumped on this. Here's what I've tried so far:


    Ensure that all headers that my subsonic restservice return are the same as the above. The original headers from the above working test were:
    Code: Select all
      HTTP/1.0 200 OK
      Content-Type: audio/mpeg
      Server: Icecast 2.3.2
      Cache-Control: no-cache
      Length: unspecified [audio/mpeg]
    and my headers are hacking apache were
    Code: Select all
      HTTP/1.1 200 OK
      Date: Sun, 14 Nov 2010 16:10:55 GMT
      Server: Apache/2.2.16 (Ubuntu)
      Cache-Control: no-cache
      Connection: close
      Content-Type: audio/mpeg
    Length: unspecified [audio/mpeg]
    Almost identical. The Connection header Apache wouldn't let me remove though (could be an issue?!)

    Ensure that the bytes subsonic streams back are correct. For this I used WGET and just piped the raw output from calling the stream api directly into a file call test.mp3 and then made request to that from audio tag in html5. This worked perfectly

    Finally I thought perhaps the url length may be causing some issues because I know that when I tried to wget without telling which file to write to linux complained because it would've written into a file with a name that was too big to support, so I've setup mod_rewrite on apache to redirect all requests from /mp3 to one specific song on the server. Sadly this failed to play also (and I made sure the redirect came back with the correct headers and bytes).


So basically I'm running short on ideas now if anyone else can think of anything else I could try then let me know. Otherwise it seems like streaming on an ipad won't work :(
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Finally got it working

Postby mattgoldspink » Fri Nov 26, 2010 12:17 am

Ok, with a bit of help from Sindre and a bit of debugging into the subsonic code it turns out that Subsonic streaming rest service will work just fine and stream MP3's to iPad, but you have to make sure that:

a) You have to pass maxBitRate=0 as a query parameter to disable transcoding (otherwise Subsonic does not send the Content-Length header which safari needs) eg: <audio src="http://yoursubsonicserver/rest/stream.view?u=username&p=password&v=1.4&c=myclient&maxBitRate=0&id=2f686f6d652f73696e6472656d656875732f6d757369632e64656d6f2f4a6f686e646f652f5079726f6d616e74696b6b2f5079726f6d616e74696b6b2e6d7033" controls />

b) You must not have a maxBitRate set for your client
c) You must not have a maxBitRate set for your user who you're logged in as (i.e. set them both to No Limit in the settings).


Issues still remaining:

1) You can only stream MP3's (if you have any Ogg or WMA files they will not play)
2) You can't set a limit

I figured the reason the norwegian streaming station works is because they're doing a continuous stream, whereas with subsonic a song ends at some time in the future and hence the "Connection: close" HTTP header is always set. So maybe a new feature would be to have a HTML streaming api/download api which transcodes before streaming and writes the transcoded file to disk so Subsonic can set the content-length header (a pretty rubbish workaround I admit but it would be great to support more than MP3 and also any bit rates).
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby sindre_mehus » Sat Nov 27, 2010 8:39 am

Glad to hear that you're making progress!

Some comments:

Are you sure about statement b) above? I think the "maxBitRate" parameter will override the per-player limit.

Regarding statement c), I think you're right (from looking at the code). However, I'll try to change it so that it too is overridden.

Pity about the required content-length. Hopefully, this will improve in later browser versions. If not, there is one potential work-around I can think of: knowing the duration of the song, and the target bit rate, it would be possible to estimate the content length (just by multiplying the two numbers). This will not be 100% accurate, but maybe it would be good enough.
Subsonic developer
User avatar
sindre_mehus
 
Posts: 1955
Joined: Tue Nov 29, 2005 6:19 pm
Location: Oslo, Norway

Postby mattgoldspink » Mon Nov 29, 2010 8:02 pm

Sorry Sindre you're right about b) it is being overridden correctly.

As for you suggestion about calculating the content-length that could work. I did a bit of digging around see that Songbird did a similar thing so it should work: http://bugzilla.songbirdnest.com/show_bug.cgi?id=16523 (assuming using cbr and not vbr). I'm happy to give it a try though.
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby mattgoldspink » Wed Dec 15, 2010 1:22 am

First version of subtunes with (very beta) ipad support is here if people wish to try:

http://code.google.com/p/subtunes/downloads/detail?name=subtunes-0.9.zip
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby kroken » Wed Dec 15, 2010 2:07 am

how to install?
kroken
 
Posts: 81
Joined: Sat Oct 16, 2010 6:28 am

Postby mattgoldspink » Wed Dec 15, 2010 10:08 am

Apologies should have sent the link: http://code.google.com/p/subtunes/wiki/GettingStarted
Let me know if you've any questions (the above page isn't great but is hopefully enough to get you started)
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby kroken » Wed Dec 15, 2010 1:52 pm

Cant get it to work, says error "Odd number of characters"
kroken
 
Posts: 81
Joined: Sat Oct 16, 2010 6:28 am

Postby mattgoldspink » Wed Dec 15, 2010 9:33 pm

@kroken

I've not seen or head of this error before. Could send me a screenshot or if you have it accessible over the internet PM me the link and I'll take a look (I don't need an account, just the url where you're accessing subtunes).

Matt
Subtunes (iTunes like for subsonic on desktop and ipad) http://code.google.com/p/subtunes/
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby mattgoldspink » Wed Dec 15, 2010 9:54 pm

Actually I've just reproduced it. I'll see if I can get it fixed.

Assuming it is the same issue, try clicking on the arrows in the tree on the left to expand instead of the words.
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Postby kroken » Thu Dec 16, 2010 12:28 pm

Your latest release fixed it, keep the good work up!
kroken
 
Posts: 81
Joined: Sat Oct 16, 2010 6:28 am

Postby mattgoldspink » Thu Dec 16, 2010 12:36 pm

Sorry I forgot to update this thread about the fix last night, glad you spotted and it worked.
mattgoldspink
 
Posts: 67
Joined: Mon Jun 21, 2010 9:24 am

Previous

Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 7 guests