Reputation: 21
I made a simple UL list: clicking on the <li> element it switches the video played by the mediaelementplayer. Works fine in desktop browsers, but with Android 2.3.6 it always plays the first video no matter on which <li> element you click. ( I tried with a Samsung Galaxy S II, but works well with Samsung Galaxy S III and Android 4.0.4)
Any suggestion on how to solve this issue?
Thanks
Here is the code I'm using:
<video id="playervideo" width="488" height="286" class="mejs-wmp">
<source src="uploads/media/video/first.mp4">
</video>
<ul>
<li><span id="first" class="current">First</span></li>
<li><span id="second">Second</span></li>
<li><span id="third">Third</span></li>
</ul>
<script>
new MediaElementPlayer('#playervideo', {
features: ['playpause','progress','duration','volume'],
success: function(media, node, player)
{
$("ul li span#first").click(function () {
media.pause();
media.setSrc('uploads/media/video/first.mp4');
media.play();
$("ul li span").removeClass("current");
$(this).addClass("current");
});
$("ul li span#second").click(function () {
media.pause();
media.setSrc('uploads/media/video/second.mp4');
media.play();
$("ul li span").removeClass("current");
$(this).addClass("current");
});
$("ul li span#third").click(function () {
media.pause();
media.setSrc('uploads/media/video/third.mp4');
media.play();
$("ul li span").removeClass("current");
$(this).addClass("current");
});
}
});
</script>
Upvotes: 0
Views: 299
Reputation: 11
You can perform a "load" event after changing the video connection
Upvotes: 1
Reputation: 45132
I wonder whether it is a timing issue on Android. I've never used that library, but poking around Google, it looks like some people have had issues with setSrc
which apparently disappeared if you wait a few seconds after calling setSrc
before calling play
.
https://github.com/johndyer/mediaelement/issues/414
Upvotes: 0