I am trying to create a page with an embedded video that will dynamically change the source when the link below the video frame is clicked. The source videos are on my host server. those. This figure illustrates this:
! [sample page] [1]
I came across this page , which seems to have an answer, but I tried, and it didn't work. Following an example, I inserted css and javascript into the desired html in the body. I updated all the links to my URLs and tried to keep the file names the same as the test example. Below I have tried.
Can someone point out my mistakes or provide a more elegant way to do this? Basically, embedded videos dynamically change when a link is clicked, and the video works in all typical browsers and most devices. This is for the wordpress site , using the JW Player for wordpress , (my mistake), instead I found this script / code actually for Video.js
It downloads a preview image but does not play.
As a test, I tried this and it plays one video correctly:
<video id="testvideo" class="video-js vjs-default-skin" width="440" height="300" controls="controls"> <source src="http://www.mywebsite.net/videos/testvid_01.mp4" type="video/mp4"/> <source src="http://www.mywebsite.net/videos/testvid_01.webm" type="video/webm"/> <source src="http://www.mywebsite.net/videos/testvid_01.ogv" type="video/ogg"/> </video>
Javascript version for multiple source links
<html> <head> <title></title> <style media="screen" type="text/css"> .wrap { margin:30px auto 10px; text-align:center } .container { width:440px; height:300px; border:5px solid #ccc } p { font: 10px/1.0em 'Helvetica',sans-serif; margin:20px } </style> <script> $("input[type=button]").click(function() { var $target = "testvid_"+$(this).attr("rel"); var $content_path = "http://www.mywebsite.net/videos/"; var $vid_obj = _V_("div_video"); </script> </head> <body> <section class="container wrap"> <video id="div_video" class="video-js vjs-default-skin" controls preload="auto" width="440" height="300" poster="http://www.mywebsite.net/videos/testvid_01.png" data- setup="{}"> <source src="" type="video/mp4"> <source src="" type="video/ogg"> <source src="" type="video/webm"> </video> </section> <div class="wrap"> <input rel="01" type="button" value="load video 1"> <input rel="02" type="button" value="load video 2"> <input rel="03" type="button" value="load video 3"> </div> </body> </html>
The preload image for the first video is being loaded, but there is no video, the error "There is no video with a supported format and MIME type"
So, I added the source for the first video in this section.
setup="{}"> <source src="http://www.mywebsite.net/videos/videos/testvid_01.mp4" type="video/mp4"> <source src="http://www.mywebsite.net/videos/videos/testvid_01.ogv" type="video/ogg"> <source src="http://www.mywebsite.net/videos/videos/testvid_01.webm type="video/webm"> </video>
The result of loading the 1st video, but not other related videos.
video names / png: testvid_01.mp4, testvid_01.ogv, testvid_01.webm, testvid_01.png testvid_02.mp4, testvid_02.ogv, testvid_02.webm, testvid_02.png testvid_03.mp4, testvid_03.ogv.pvidvid_bv.bv.bv.bv_vm_vidb03.vv
I tried this on both the wordpress page and the html page, the results are the same.
I'm not sure even if this script will do what I want?