I have an embedded Windows Media Player object in my website and I'd like to make it skip ahead to a certain point when the page loads. Most sites suggest using:
mediaplayerID.controls.currentPosition=xxx
That works great in Chrome but IE throws up a JavaScript error saying that mediaplayerID is undefined. I assume the issue is that the script is running before the media player object is fully loaded -- after the video starts playing, I can run set the currentPosition in the Developer Tools console and it skips ahead like it should. Is there a way in JavaScript to detect when (or wait until) media player is loaded and then change position?
Related
playSound : function() {
var audio = new Audio(audio.mp3);
audio.play();
}
I am using the above code to simply play audio. But I am facing two issues below:
The sound never plays till I click on the tab (for this I go to another tab and then click the current tab). Seems it needs an event before playing sound.
Sometimes I get exception and audio never plays "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first."
I don't want to mess with HTML element.
You're likely seeing the policy change for autoplaying media on websites issued by Chrome: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
In essence, the policy says that unless the user interacts on your media and your handler* does not start the media synchronously, it will not play.
Notice the word synchronously - you can't even use setTimeout or some such. This is to protect the user from spammy ads and alike. The other browsers have this as well, as a setting, but they might and likely will enable this by default, so you better get ready for it.
[*] - (e.g. click handler)
I have an Icecast server serving AAC+ (HE v2). I use JPlayer in my webpage to play the content. In Chromium without Flash Player it works just fine.
For Flash enabled browsers it does not work out of the box. I read that Icecast wants to have a "type=.flv" appended to the stream request to make the content playble by Flash Player, and although I have trouble finding the Icecast documentation about it, indeed it works on Firefox with Flash Player 11. But it does not play on other browsers with Flash 15 and above, namely Google Chrome on Linux, Firefox and Internet Explorer on Windows. Google Chrome plays it just fine by disabling Flash Player.
The audio data are downloaded correctly as shown by Developer Tools, audio is heard for about one second and then silence.
Is there anything I can try to make AAC+ playback possible with Flash Player ?
A link:
http://148.251.184.14:18044/chr_xmas
By default it returns a header with Content Type audio/aac. By appending "?type=.flv" (with a dot), it returns Content Type video/x-flv.
Turns out this is a jPlayer issue. I noticed at the bottom a mention by a jPlayer fork with a crude hack which is good enough for my purposes.
It didn't work right off the bat though, I changed the line to
if( myStream.bytesLoaded > 2048 ) return 1;
as it seems that in my case bytesTotal was not uint.MAX_VALUE. I had to compile a new .swf with flex and it worked like a charm on Firefox and Internet Explorer.
I am trying to tell if my video is going to play inline once the user starts the video (as apposed to fullscreen/in the native video player) on an iPhone in a UIWebView before the video has started. I have no way of knowing if the UIWebView has the setting allowsInlineMediaPlayback = YES as i do not know in what app or on what page my video is being displayed.
My goal is to only show the video if it can be played inline.
Is there any way to read the allowsInlineMediaPlayback setting from javascript, or detect if my video will play inline or not?
Everything I have read on the apple developers website seems to suggest that it will automatically play in full screen mode in safari. Now if they are using another app, as far as I know you do not have access to that apps UIWebViews properties. However, in an attempt to not be totally useless, here is a link to all of the methods you can query and you might find some useful information in there.
https://developer.apple.com/library/safari/documentation/AudioVideo/Reference/HTMLMediaElementClassReference/HTMLMediaElement/HTMLMediaElement.html#//apple_ref/doc/uid/TP40009355-CH18-SW27
Some more information that may be useful to you.
https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/AudioandVideoTagBasics/AudioandVideoTagBasics.html#//apple_ref/doc/uid/TP40009523-CH2-SW1
I have used video.js for several videos on two previous projects. The projects were cross browser and work fine.
On project 3 I set up the video reference in a floating div like so...
I get the following error from Firefox on loading the page into the browser...
Media resource tio4.mp4 could not be decoded. tio4.php
All candidate resources failed to load. Media load paused.
I attempt to play the video subsequently with...
videojs("example_video_1").play();
but (of course) it does not play.
Swapping tio4.mp4 with a video from a previous project I have no problems.
Running tio4.mp4 (The video that gives the "could not be coded" error) in Movie Maker shows the video running fine.
Do I need a refinement in my video reference? What else?
The original video (The one giving me the problems) was formatted in an obscure tool.
I put it in Movie Maker and tried saving it which made no difference. I then cut a tiny piece off the Movie and saved it as a "clip" which worked on this one and a subsequent one!
We are developing a Javascript web app for the Ipad that requires sounds to be preloaded before it loads. We don't know what sounds the user needs until they click on an exercise and then they need multiple sounds to be preloaded before the exercise starts.
I am aware there is no preload method, and that the download needs to be bound to a direct tap / click event. We have spent a considerable amount of time trying many combinations of adding media elements dynamically on every click (loaded with dummy sounds) and then trying to swap them with the mp3's we need at the time.
We have given up on that approach and thought we could just join the sounds into one file and move the play head to the desired ranges (contained in a JSON file). We got this working successfully on the desktop but we can't do it on the Ipad because we don't know when the sound is completely downloaded.
Even after the user initiates the sound to be played, the device has no method for checking when the sound is fully downloaded. In fact, it doesn't download the whole file unless it is playing. What we have discovered is that we can not consistently get the duration unless the play head has reached the end in a linear fashion. We have tried to check the buffered.start() and buffered.end() properties against our own duration (we have the JSON file with all the times) but as soon as we try and set audioElement.currentTime and stopTime, it just plays the whole sound from beginning to end.
We have found that the seekable property to be unreliable as well.
We are now working with ios5 and I believe that older versions work differently in regards to the duration property.
Has anyone been able to get this working?