javascript - Playing corresponding videos to different links in HTML5 Video -
I am using HTML5 video tags to play video on my website. When a certain image is clicked, I want it to pull the video player and play the same video. Any ideas about how to do this and make it compatible in all browsers?
is the video player, so I want to change it based on the image being clicked
& lt; Video width = "320" height = "240" control & gt; & Lt; Source src = "" class = "video player" & gt; & Lt; Source src = "" class = "video player" & gt; & Lt; / Video & gt;
Clicked with images
& lt; Img src = "picture / 1.jpg" class = "boxImage" data-project = "project" data-video = "picture / portfolio / test webm, image / portfolio / test.mp4" & gt; & Lt; Img src = "images / 2.jpg" class = "boxImage" data-project = "project" data-video = "picture / portfolio / test 2. webm, picture / portfolio / test 2.mp4" & gt;
var video = document.query selector ('video'); Video.oncanplaythrough = function () {video.play (); }; $ ('. BoxImage') ('click', function) {var data_videos = $ (this) .data ('video'). the division (','); (Var i = 0, l = data_videos .length; i & lt; l; i ++) {var mime_type = 'video /' + data_izable [i] .split ('.'). Pop (); If (videoconplay type (mime_type)) {video.src = data_videos [i break; }}});
Comments
Post a Comment