English 中文(简体)
Still trying to stop video from rewinding in mediaelement.js
原标题:

I am still having problems with the code not stopping the video from rewinding to the beginning. The code that John posted doesn t seem to be working for me.

He said:

I believe that the default behavior of the element is to go back to the beginning so you d just need to override this by listening for the ended event.

var player = $( #myvideo ).mediaelementplayer();

player.media.addEventListener( ended , function(e) {
    player.media.setCurrentTime(player.media.duration);
}, false);

I placed the code in the <head> and in the <script type="text/javascript"> on the page with the video and it isn t working... it still rewinds to the start.

What am I doing wrong?

问题回答

I wrote a fix for this problem and John merged in version 2.10.2. There is now an option "autoRewind" that you can set to false to prevent the player from going back to the beginning. The eventlistener is not added and there is no more need to remove it.

$( video ).mediaelementplayer({
    autoRewind: false
});

This worked for me, you need to call the methods on the DOM object not the jQuery object.

var player = $( video );
player[0].addEventListener( ended , function(e) {
                player[0].setCurrentTime(player[0].duration);
            }, false);

I think the best solution is to edit mediaelement-and-player.min.js (if you are using that)... do a text search for c.media.setCurrentTime(0) and comment it out or delete it.

should be

player[0].player.media




相关问题
MediaElement.js jquery bug

I have an gwt application and I use MediaElement.js to show multimedia contents. If I put on the main page this script <script> // using jQuery $( video,audio ).mediaelementplayer(); <...

FancyBox + MediaElement player + IE

Trying to incorporate the mediaelement.js player into a lightbox (fancybox.net). Player works in IE without FancyBox. FancyBox works in IE with regular text content. But The player + fancybox ...

Still trying to stop video from rewinding in mediaelement.js

I am still having problems with the code not stopping the video from rewinding to the beginning. The code that John posted doesn t seem to be working for me. He said: I believe that the default ...

Continuous play for Mediaelement.js

I have a music blog (http://www.lowerfrequencies.com/) in which I have and embed Mediaelement.js audio file in every post. It works great and I have no complaints. However, I would like it if I could ...

Mediaelement.js javascript error in IE

I m using MediaElement.js as my HTML5 video player for a site in progress. It works fine in Chrome, Safari, and Firefox, even with the fallback player, but in Internet Explorer I get the Javascript ...

热门标签