Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid autoplay #58

Open
skenklok opened this issue Nov 21, 2013 · 2 comments
Open

How to avoid autoplay #58

skenklok opened this issue Nov 21, 2013 · 2 comments

Comments

@skenklok
Copy link

Hi,
i have a problem when i switch from one playlist(youtube) to another, i can't stop auto-play of new video. How to load the first element of the playlist without auto-play?
can you help me please?

This is my code:

minplayer.get('media', function(media) {
media.stop();
minplayer.get('playlist', function(playlist) {
playlist.options.playlist = path;
playlist.options.autoplay = false;
playlist.load(0, 0);
})
});

Thanks

Marco A.

@travist
Copy link
Collaborator

travist commented Nov 21, 2013

Yeah, this is done intentionally, so it may be hard to override. Here is the code that does this.

https://github.com/mediafront/osmplayer/blob/2.x/src/osmplayer.js#L137

What you may be able to do is hook into the event handler, and alter the data.autoplay before it makes it to this code. You can also force the options within the player which should handle the case if your event handler is called after the playlist load. Here is what I am thinking, but I have not yet tested it.

minplayer.get('player', function(player) {
  minplayer.get('playlist', function(playlist) {
    playlist.bind('nodeLoad', function(event, data) {
      data.autoplay = false;
      player.options.autoplay = false;
    });
  });
});

@skenklok
Copy link
Author

HI thanks for your reply, my code load at the same time the playlist and the first element of it, so i'm not able to hook into the event handler before the loading. I've also try to stop the media but this intrudes every time i play any item. There's other similar solution or you've any others idea?

minplayer.get('playlist', function(playlist) {
                        playlist.options.playlist = path;
                        playlist.options.autoplay = false;
                        playlist.load(0, 0);
                        // Bind to the play event of the media.
                       media.bind('playing', {obj: this}, function(event) {
                           media.pause();
                        });
 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants