videojs / videojs-youtube

YouTube playback technology for Video.js
1.12k stars 549 forks source link

Changing source of playing youtube video to an mp4 video doesn't work #347

Closed adamtal3 closed 8 years ago

adamtal3 commented 8 years ago

I've created a video player that can show videos from youtube or mp4 videos.

When the player is loaded on a youtube video, calling src with an mp4 source does nothing.

Example: http://jsfiddle.net/kocca6sb/1/

Can anyone spot the issue with different techs source changing? Is it really youtube plugin related?

narration-sd commented 8 years ago

I can give you a work-around -- really what it does is not try to use the youtube tech when playing an mp4. Quite possibly this is something the youtube plugin might arrange for itself.

I think the proper setup (someone may correct me on this) is that when playing an mp4, we should identify video-js.swf as the tech. This is so the swf player included with video-js will be used as fallback for browsers that don't do mp4 natively.

And naturally you want to be sure your source is labelled with the propermime code.

Here's how that works out:

<video id='yourid'
        ...rest of your setup...
    data-setup='{"techOrder" : ["youtube"]}'>

<source src="https://youtu.be/yourvideocode" type='video/mp4' />

Or, you could as seems hinted by the examples, just set techorder to empty brackets ({}) and include a nojs warning to upgrade to a modern browser that supports mp4. Empty brackets (think it defaults to that if you just leave data-setup out) works fine if you have such a browser and video/mp4 source.

gkatsev commented 8 years ago

It looks like the issue is that tech doesn't dispose itself properly and the youtube iframe stays around when the video is changed.

gkatsev commented 8 years ago

A new version with this fix is now released.