Here's some sample code, with XXXXs marking what wasn't working for me (in any browser).
Now it turns out the reason these functions didn't work is not that browsers suck and this whole HTML5 is hugely overrated (my initial reaction), but was in fact that the server serving the MP3 files did not support streaming. Of course if would have been nice if somehow the audio object would warn me about this rather than sitting there doing nothing, but you can't have everything.
Anyway, now the question was how do I make my server support streaming? Do I need to sign up for some kind of premium service? Or spend weeks implementing a streaming sever?
Thankfully not. It turns out you 'simply' need to make your server support HTTP Range requests. If your server uses PHP, you're in luck. I've got a complete working example which I can share with you right now.
Note I did not write this code, I found it here and added it to gist for posterity.
Simply add this code to your PHP server, and when you're about to serve an MP3 (or OGG or whatever) call this function.
For reference, I call the function like this (where $fullPath is the absolute path to my MP3 Resource).
smartReadFile($fullPath, basename($fullPath), 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3');
You sir... are a badass. That script is freaking awesome. Solved my issues. Thanks so much!
ReplyDelete-Jake
I have encountered an issue with setting currentTime but I don't think it has to do with streaming because I preload the sound file first. My problem seems to be related to contexts. I start the Audio object from the window but when I try changing the value from XMLHttpRequest response it does NOT work.
ReplyDeleteHave you seen anything similar? my issue is posted below.
http://stackoverflow.com/questions/17664181/html5-audio-does-not-play-more-than-once
thank you!
DeleteMan, this post made my day at work. I'm working with a tool at the callcenter I work to and the server (in Lua) was not serving the mp3s correctly. Thanks to this headers that you showed I can now skip some parts of the audio and play correctly in the browser.
ReplyDelete<3
Wow amazing i saw the article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing and please keep update like this type of article because i want to learn more relevant to this topic.school websites uk
ReplyDeleteThank you very much! Works perfect!
ReplyDeletehtml language samples for beginners
ReplyDeletehtml code Image shape circle
You save my day ! thx a lot :)
ReplyDeleteAn astounding web diary I visit this blog, it's inconceivably magnificent. Strangely, in this current blog's substance made point of fact and sensible. The substance of information is instructive.
ReplyDeleteOracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Faktor penentu itu bisa dibilang penerapan strategi yang digunakan saat bermain, untuk itu perhatikan ulasan terus ini.
ReplyDeleteasikqq
dewaqq
sumoqq
interqq
pionpoker
bandar ceme terpercaya
hobiqq
paito warna terlengkap
bocoran sgp
It was really fun reading ypur article. Thankyou very much. # BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page
ReplyDeleteOur Motive is not just to create links but to get them indexed as will
Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain
High Quality Backlink Building Service
Boost DA upto 15+ at cheapest
Boost DA upto 25+ at cheapest
Boost DA upto 35+ at cheapest
Boost DA upto 45+ at cheapest
It was wonderfull reading your article. Great writing styleiamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder
ReplyDeleteDavid Forbes is president of Alliance Marketing Associates IncIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder
ReplyDeleteWe are used to the fact that we know only religious and public holidays and celebrate only them.Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder
ReplyDeletehow led lights work, how do led lights work, how do leds work, how does the light bulb work
ReplyDeleteLooking for the proper led strip lights or led lights under bed? Find shopping tips and recommendations for the best LED light strips in this buying guide!
ReplyDeleteled under bed Under bed lighting adds a wow factor to your slumber spaces. Whether you're looking for LED or motion-sensing lights
ReplyDeleteIGRS Telangana portal is the all type services provide in telangana state
ReplyDeleteOptimize your fitness facility or gymnasium by using high-quality lights. Learn more how led gym lights can help you achieve the best atmosphere.
ReplyDeletecan you cut led lights are such a versatile product due to the fact that they can easily be cut on the given cut lines and connected at any point between the copper dots on the LED Strip Lights, cut lengths vary between products.
ReplyDeletewhat color led light helps you sleep? ... A red light color is best for sleep because it has a low color temperature, far lower than regular sunlight.
ReplyDeleteAnd here's the pool led strip lights project I was trying to remember, this one was for installed Pentair lights. Not strips, but a lot of color options.
ReplyDeletebest camping lanterns that are built not only for your satisfaction but also for your safety, so buy a Fenix camping lantern.
ReplyDelete8ft led shop lights is a great option for lighting up garage, basement, work areas, rooms etc.. It could be plug & play or hardwrie to wall switch.
ReplyDelete