Detect when HTML5 audio stream started playing or failed to load

I'm working on an application audio streaming using the HTML5 and webkit browser. I created an audio stream using code similar to the following:

var = new Audio audio
audio.setAttribute ("src", "url of feed to play here");
audio. Play();

I would like to be able to tell the user:

(1) when the feed was loaded and gets ready to play. This is because the stream can take a long time to load and I want to inform the user that the application works.

(2) when a feed failed to load. If the flow is interrupted for some reason, I wish to inform the user that something did not.

Does anyone have any ideas on how I can do this?

There are a lot of events and properties on the media items. For example, you can add an event handler for the 'mistake' to detect if the load fails. The 'loadeddata' event is raised when data is actually down. There is also an event of 'progress', but I have not much used. There is an event of 'game '.

I'd be a little careful about the assumptions of State - for example I would not be surprised if the press started playing before being fully charged. Seems to me the type of optimization that someone might throw together

So I threw the following test code.

appstart = function() {
    var main = document.getElementById("main");

    var b = document.createElement("button");
    var t = document.createElement("div");
    var a = document.createElement("audio");
    b.innerHTML = "Play";
    b.addEventListener("click", function() {
        a.addEventListener("timeupdate", function() {
            t.innerHTML += "Played "+a.currentTime+" of " + a.duration + "";
        });
        a.addEventListener("progress", function() {
            t.innerHTML += "Progress";
        });
        a.addEventListener("load", function() {
            t.innerHTML += "Load";
        });
        a.addEventListener("error", function() {
            t.innerHTML += "Error";
        });
        a.addEventListener("playing", function() {
            t.innerHTML += "Playing";
        });
        a.addEventListener("stalled", function() {
            t.innerHTML += "Stalled";
        });
        a.addEventListener("loadeddata", function() {
            t.innerHTML += "Loaded";
        });
        a.src="long.mp3";
        a.play();
    },0);
    main.appendChild(a);
    main.appendChild(b);
    main.appendChild(t);
};

window.addEventListener("load", appstart, 0);

Tags: BlackBerry Developers

Similar Questions

  • Detect when a flv is done playing

    I know this has been asked before but I'm a true dumby when it comes to action script, so I was wondering if anyone would be enough to set out for me line by line.

    I'm looking for code that would allow me to detect when a flv has finished play and move the playhead to the next section. In order to set this up, I have my flv on frame 1 (instance name 1) and I want that it automatically 'Stop' structure 2 after the "1" play.

    I hope that makes sense - thanks for looking

    Tim

    Try:

    VID1.addEventListener (VideoEvent.COMPLETE, changeFrame);

    function changeFrame(evt:VideoEvent):void {}

    gotoAndStop (2);

    }

    (I don't know if you need too... import fl.video.VideoEvent;)  before that)

    You should take the time to familiarize themselves with the help documentation.  Each class is documented there, and each has its properties, methods, and events detailed/defined.  Once you become familiar with the general idea of how these 3 elements are used, the help docs becomes a great quick reference to understand all what you need to do.

  • I just started to have "Failed to load actuions because an unexpected end of file has been detected" in Photoshop CC

    I just started to have "Failed to load actions because an unexpected end of file has been detected" in Photoshop CC. It was working fine yesterday, but when I opened this evening warning came.

    Looks like the *.atn file is possibly corrupted.

  • HTML5 audio problem: Multiple-play audio

    Hello

    We recently discovered a problem when the publication for HTML5, where audio is not playback from the beginning.

    Using Captivate 9, if you have a page with several buttons on stage who each action Play Audio, you expect each button when you click it to play the audio from the beginning. It works as it should when you press the buttons for the first time. However, if you click on another button before your audio has finished and then selected the initial button once again, instead of the audio file from new from scratch, it resumes from the point where you left the first time.

    This problem only occurs when you view a published HTML5 course. If you publish to SWF, or listen to samples in Captivate, the buttons act as intended and play the audio from the beginning, whenever a key is pressed. We also tested in several browsers, all with the same result.

    Ideas or workarounds on it?

    See you soon,.

    Ross

    Hi all

    I noticed that since the Captivate update to 9.0.2 this issue is no longer appears, Yes!

    Ross

  • Sound preview audio stream starts beginning rather than at the current position in the timeline

    I have an audio stream which I'm doing an animation. After working for a while, especially later in the video (like 2 minutes or more). audio will not play at the position, I'm in the workspace and rather play early instead. It is therefore impossible to work efficiently synchronize audio animation.

    I tried with several computers and sound cards, and I get the same behavior.

    What is going on? Is this a known bug?

    Yes, it is a known problem in Windows. I have reason to believe that it will be corrected in the next update to Flash Pro. Don't know when this will be.

  • error occurred when copying audio streams

    So I bought this product and installed and spent about 2 hours going through the tutorials. Now, I decided to make my first record of the sample of a web-based program. I created a new recording project /, size the window, etc. I click on folder, connect to the application, press END on my keyboard and it shows that savings and then BAM, I get "error encountered during audio stream copy" as a small box to pop up. I have no audio turned on or anything. How can I solve this problem?

    I'm fighting the same exact error. I installed Captivate on my other laptop and it worked fine so I thought well, remove it from the original laptop and see what I can do from there. When I went into the Control Panel - Add/Remove programs I couldn't find Adobe Captivate so I ran a installation, check the Add/Remove programs and now he's here, and when I try now to create a project it works... go figure. Don't know what it was but I did check the sound settings in my control panel of two laptops and both were the same, all that I checked were the same - one worked there isn't. The only difference I've found that the laptop which didn't work had the application was on the Add/Remove window, but I was going to start - programs - Adobe Captivate to start if she should have been there. Re-install and see what happens.

  • range poor when bluetooth audio streaming

    My Macbook 2015 beginning has brought very poor when audio streaming to bluetooth speakers. my laptop should be in 1-2meters for clear sound without interruption. the most and jump in and out sounds like and scratched old CDs. not in any wall or something just to work from one end of my room the other maybe 3 meters... I have a bar of his sony with streaming audio bluetooth and one pill of beats the range is compatible with the two speakers. If I use my iPhone 6 paired with the same speakers the beach is really good 6 + meters... I've already had the laptop replaced from jbhifi for this problem and the replacement is identical. have apple cheeped out on the inner workings of bluetooth on this model?   I was wondering if anyone else has similar problems of bluetooth with these new MacBook?

    No, my bluetooth works fine. I can even run around the House with my bluetooth headset. I could say, mine is 20 meters. Not sure, but I can go very far with it

  • Error when, with audio streaming via HTTP to the Simulator

    I use JDE 4.7 and 8900 Simulator.  I'm trying to listen to an MP3 via http to a blackberry app.  When you use the BufferedPlayBack example screen, I get the following error when the data source is trying to open the connection - "net.rim.device.cldc.io.dns.DNSException: error trying to solve.

    When I enter the same URL in the BlackBerry browser on the Simulator, I get the following error: "the selected server returned an error when you try to respond to your request.

    When I enter the same URL in my web browser in my PC, I am able to stream audio and play with QuickTime.

    Why I get this DNSException on the BB and not on my local PC?  The web engine runs also locally.  I know that the BB Simulator does not support rstp.  The Simulator also not does support streaming over http?

    This is the URL I used:

    http://myLocalMachine:8080/myMusic/anAudio.MP3;deviceside=true

    Thanks in advance!

    T

    I found a solution to the question in the thread below.  I increased the connection. MaxNumberOfKBytesToSend = 10240 in the... File MDS\config\rimpublic. Property and so was able to sucessfully stream mp3 to my request.

    http://supportforums.BlackBerry.com/T5/Java-development/increase-MDS-CS-limit-on-http-download-size/...

  • Notebook PC from HP 15 15 t-r000: no videos or audio will start playing on my laptop

    For some reason any I can't understand why my laptop is not playing any kind of music or videos. I can press the play button but nothing starts. Not youtube or iTunes, or if I tried to say iHeartRadio for listening to music nothing plays. Even if there are videos on other sites I press play and nothing goes. I'm not sure exactly what would be the problem, he worked to find a few days ago. If yesterday I noticed a few videos, I tried to play wouldn't work, I thought it was just youtube being wonky, but it worked fine on my phone and now because nothing really works on laptop, I guess may be something with the computer. As far as I know it is a simple solution, but at this point, I don't even really know.

    I just check one of my games also and I hear no sound from him now. I play, but even with all audio bent under the sets of options and I don't hear any sound. Nothing is cut on my computer I am aware of and even if she was silent, I don't know why this would prevent all the videos to play with or without sound.

    The new test I tried to open a video chat on Skype with my cousin and it kept failing to go through. Then, we tried with audio Join.Me session what we do often. She could hear me very well, but my end was filled with nothing else than silence. I couldn't hear anything, she said.

    So not quite sure what to do at this point. I hope that I have explained everything well enough however. I did not have the computer is not even a year either.

    Hi @MakiTokito,

    Thank you for visiting the HP Forums! A place where you can find solutions for your problems with the help of the community!

    I stumbled upon your post on the laptop, and I thank you for detailed information about what is happening and what you did to remedy. VERY USEFUL! I looked in your question about your laptop HP 15 t-r000 and issues with not able to get the Audio working properly.

    You could solve the sound here.  The document indicates for Vista, but it works very well under Windows 7.

    In under his right click Device Manager and update driver.

    With video does not properly or green. Try clicking on the green screen, in the tab named storage Local and put 10 k and the green screen should disappear.

    Here is a link to the HP Support Assistant, if you need it. Just download and run the application and it will help with the software and drivers on your system that need to update the graphics driver may need to be updated.

    Have you tried another browser? This link will help you to upgrade your browser if necessary. Check your extensions, plugins, cache and cookies.

    Please let me know how it goes.

    Thank you.

  • HTML5 Audio does not play

    I packed up and signed my application continuously using ripple. When I load on a handset and open it, everything seems fine. But when I click on the link to read a stream, the stream does not play.

    I put my config file to allow access to all external URLS, but the sound does not always play.

    I found that the stream plays when on a physical blackberry browser pointing to the url to dropbox.

    However, the changes in the display are so slow, and the stream takes so long to buffer, I can't possibly release the app in its current state. I hope that when I get all the data to the device instead of running a web URL, performance will be better.

  • Live audio streaming on the flash site

    Hello

    I'm new to Flash and I'm working on a web page using flash, the page itself is going to be pretty basic, but the situation in that I am is the following, we would like to but a stream live audio feed on the site and I can't find how to add that.  The server it comes is a Broadwave server, and it MP3 stream.  I wish the audio stream starts automatically when the web page is opened.  Any help would be greatly appreciated.

    You can build your own player, but if you are new to Flash, you might want to just incorporate or place a pre-built player on the Web page. For example:

    http://www.longtailvideo.com/players/JW-FLV-Player/

    or

    http://flowplayer.org/

    or

    http://ffmp3.sourceforge.NET/

    each player will have its own configuration config for autoplay etc.

    Best wishes

    Adninjastrator

  • Windows Vista ultimate Media Center Audio CD starts, but after a 1 Minute Audio stops C00D0FAB ErrorCode

    Audio CD starts playing. After about a minute, the audio stops and I get an error message indicating "YHE DISK IS EITHER DIRTY or DAMAGED.

    Please try playing some other audio CD. This happens with all audio CD, or just this one?

  • Firefox does not play HTML5 audio

    My Firefox installation (v33) does not play HTML5 audio.
    I am referring to audio tracks (MP3) you can listen to on your personal Google Reader. The stream does not start, there is no time of the track being filled.

    -Youtube HTML5 player works great both for Audio and video
    -J' tried Incognito mode (without cache and cookies)
    -Tried restarting without Add - ons (I use Adblock and other stuff)
    -Tried to restore Firefox.

    None of these permits.

    -V38 IE11 and Chrome, the browser listen very well
    -A clean Firefox (on my virtual machine, for example) very well disseminate

    Any tips?

    EDIT: SEW I'm touched by it? https://Bugzilla.Mozilla.org/show_bug.cgi?id=911837

    You can file a bug in the Mozilla bug tracking system: https://bugzilla.mozilla.org/ (see: https://developer.mozilla.org/docs/Mo.../Bug_writing_guidelines)

  • HTML5 video: video freezes regularly while only audio continues to play. Firefox 12, Linux, Centos 5 up to date.

    whenever I find a YouTube video on my linux (Centos 5.8, completely up to date) using Firefox12 machine, YouTube still offers for me html5 instead of Flash video. It would be nice, but intermittently the video stops (while the audio continues to play). I click on the (I don't know how it's called) cursor to the current position and the video will move again. until he paused next time, anywhere from a few seconds to a few minutes.
    I don't know why he delivers html5 instead of flash, I get on my laptop using centos 6 and firefox12 flash video. Is there a way to configure Firefox to get flash instead? If this isn't the case, I would be grateful for help when the video component setting stopping.

    You may be on the Youtube html5 trial. http://www.YouTube.com/HTML5

    mha007, these three macromedia inks are more for Windows and not Linux.

  • iBook randomly started playing when the phone is turned off

    Just noticed this with the upgrade to iOS9. The phone is off (i.e., black screen, but still able to receive phone calls or be activated with PW or digital), and iBooks starts reading my audio book. We then see the iBook controls in the lock screen. No one touched the iPhone 6.

    Does anyone else have this problem? Suggestions to prevent it from happening would be greatly appreciated. Thank you.

    Maybe it's not a specific question of iBook. My iPhone is not actively running - sometimes even just sitting on a table across the room to anyone - lights sometimes at random a random application without apparent reason. (This is especially awkward when he phones random random contacts!) Or, as you say, starts playing audio.)

    I don't know what causes it, and I didn't notice all the reasons for this behavior. I think if the phone was turned off in fact he wouldn't do this, but that sort of impact at the point of having a phone in the first place.

Maybe you are looking for

  • How to add searchable keywords/notes

    How add searchable notes/tags to my emails incoming and outgoing, who can help me find an e-mail related to a note/keyword specific. Help, please.

  • Where to download Windows 7 pro oa for ThinkPad L412.

    Hi all. I have a ThinkPad L412 notebook with the product key of Windows 7 Pro OA. but with changed the HARD drive. Can someone advice which the ISO of Windows 7 Pro I can use to reinstall windows? I try to download the picture of http://www.microsoft

  • Syntax error when you use FindIndex in TestStand functions

    Hi all I used this function well before that was functional for me, but don't know what I'm doing poorly able to do my work. This is my scenario, I have a local variable of the table 1 d of chain bear (Locals.XXX) I need to get the first value of the

  • Compaq CQ58-300SM

    Where can I find drivers for Compaq CQ58-300SM for Windows 7 64-bit, since there is none in the download menu?

  • I use Google Chrome only.

    I only use Google Chrome and now for some reason when I click on the icon on my desktop I get another www.searchqu.com research field.   I found it listed in the control panel and click on it to uninstall.  He started to uninstall it, but then a mess