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

Do not autoplay if there is no source #2971

Closed
wants to merge 1 commit into from

Conversation

forbesjo
Copy link
Contributor

@forbesjo forbesjo commented Jan 5, 2016

This PR prevents the player from calling play() with autoplay and no source. In Firefox this would fire a 'play' event (See http://jsbin.com/vubugev/edit?html,console,output). For some reason this doesn't happen in Chrome.

@gkatsev
Copy link
Member

gkatsev commented Jan 5, 2016

We probably should make sure that when a source is then added it'll get autoplayed. Does this happen in your testing? We may or may not want to have a similar check inside of player#src

@forbesjo
Copy link
Contributor Author

forbesjo commented Jan 5, 2016

setSrc() in the Flash tech does check for autoplay and calls play(). The HTML tech just lets the video element deal with it. I've checked and after I call src() the video does automatically play.

@forbesjo
Copy link
Contributor Author

forbesjo commented Jan 7, 2016

@gkatsev wondering if you have any more comments on this one.

@gkatsev
Copy link
Member

gkatsev commented Jan 8, 2016

LGTM.
We probably should have a story at some point about fixing autoplay completely.

@gkatsev gkatsev closed this in 867fec9 Jan 8, 2016
@jamesgorrie
Copy link

The problem with this seems to be that if I have specified <source src="../thing.m3u8" type="video/m3u8"> player.src() is then "" (or !). Is this a bug when setting src? If so I can file it.

@gkatsev
Copy link
Member

gkatsev commented Feb 2, 2016

video/m3u8 isn't a correct mimetype for m3u8/HLS content.

@jamesgorrie
Copy link

Apologies (And thanks for the heads up).

We are supplying multiple sources, and even when only serving the mp4 content we don't see the player.src() populated. Only when we add the src attribute to the video element itself.

e.g. of video element:

Not working

<video class="vjs-tech" preload="auto" aria-hidden="true">
  <source src="https://example.com/example.mp4" type="video/mp4">                
</video>

Working

<video class="vjs-tech" preload="auto" aria-hidden="true" src="https://example.com/example.mp4">
  <source src="https://example.com/example.mp4" type="video/mp4">                
</video>

@gkatsev
Copy link
Member

gkatsev commented Feb 2, 2016

Can you open a separate issue for this? Thanks.

@gkatsev
Copy link
Member

gkatsev commented Feb 2, 2016

Also, if you can include a working test case on a site like jsfiddle, that would be best.

@jamesgorrie
Copy link

Okay - after quite a bit of digging, it appears it has to do with the fact that, if a page is loaded, we have a currentSrc set.

This then doesn't run the setSrc function as the current.src === this.el_.src

So either this PR should include:

if ((this.src() || this.currentSrc()) && this.tag && this.options_.autoplay && this.paused()) {
//...
}

Or the setSrc method should be updated.

Here is an example where autoplay won't work when we have currentSrc set from the browser.

@jamesgorrie
Copy link

Created an issue here #3071

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

Successfully merging this pull request may close these issues.

3 participants