-
Notifications
You must be signed in to change notification settings - Fork 547
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
Is it possible to change the src? #339
Comments
I added an example in example/youtube-javascript.html. You should be able to change the source with javascript now. |
Kool. Thanks. <!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="http://vjs.zencdn.net/5.4.4/video-js.css"/>
</head>
<body>
<video
id="vid1"
class="video-js vjs-default-skin"
controls
width="640" height="264"
data-setup='{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "https://www.youtube.com/watch?v=xjS6SftYQaQ"}] }'
>
</video>
<button id="change">change video</button>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://vjs.zencdn.net/5.4.4/video.js"></script>
<script
src="https://raw.githubusercontent.com/eXon/videojs-youtube/637a2916c2c4fd2b5fc55dafa3df923a92fec6d0/src/Youtube.js"></script>
<script>
(function ($) {
$(document).ready(function () {
// An example of playing with the Video.js javascript API
// Will start the video and then switch the source 3 seconds latter
// You can look at the doc there: http://docs.videojs.com/docs/guides/api.html
videojs('vid1').ready(function () {
var myPlayer = this;
myPlayer.src({type: 'video/youtube', src: 'https://www.youtube.com/watch?v=y6Sxv-sUYtM'});
$("#change").on('click', function () {
myPlayer.src({type: 'video/youtube', src: 'https://www.youtube.com/watch?v=09R8_2nJtjg'});
});
});
});
})(jQuery);
</script>
</body>
</html> |
Awesome thank you :) |
Thanks for this! It's strange that the html5 video js api can't accept multiple sources, the way the html element can. I ended using Modernizer re http://stackoverflow.com/a/5371478. Just putting this here for anyone else landing on this thread. |
Just an information: in IE11 (mode IE10) direct usage of |
I don't know what I'm doing wrong, I followed the code example but when I click on the change button, nothing happens. |
Hi, I'm interested in manually triggering the playing of different youtube urls using the same html video tag (if possible).
I saw this code which gives me hope that this is feasible: http://jsfiddle.net/mister_ben/g7mrs/
But this is old code (videojs version 4.1 and an older version of the videojs-youtube plugin),
and upgrading to the current versions just doesn't do the trick.
Is there an easy work around?
Actually, digging in the closed issues, I found this issue:
#241
which is the same as mine.
I'm using this code on firefox with mac 10.11.1:
and my error message (in firebug) is:
TypeError: this[method] is not a function (from video.js line 10195, col9)
The text was updated successfully, but these errors were encountered: