Hi after coding a tutorial on how to make a media player I find that i cannot connect to any media with an absolute URL. After having made a diligent search for the answer W3schools and elsewhere the syntax still seems unclear in my mind. As far as I am aware the source tag is used and can be used to target different media types eg, ogg, webm, mp4, for example,
<video id='media-video' controls>
<source src="fish.mp4" type="video/mp4">
<source src="fish.webm" type="video/webm">
</video>
My question is this, is it possible to use an absolute URL with the source tag in this way and what is the syntax for doing so? kind regards and thanks for taking the time - robbie
guys could you take a look at this, i apologise as its not strictly html and css but it contains the script also, as you can see the media player calls certain functions one of which should be the onclick function to load the now relative url, but it doesnt work! ahhh is there no life without pain! Any ideas?
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Sample Media Player using HTML5's Media API</title>
<link href='media-player.css' rel='stylesheet' />
<script src='media-player.js'></script>
</head>
<body>
<h1>Sample Media Player using HTML5's Media API</h1>
<div id='media-player'>
<video id='media-video' controls>
<source src=http://www.youtube.com/myvideo type="video/mp4">
</video>
<div id='media-controls'>
<progress id='progress-bar' min='0' max='100' value='0'>0% played</progress>
<button id='replay-button' class='replay' title='replay' onclick='replayMedia();'>Replay</button>
<button id='play-pause-button' class='play' title='play' onclick='togglePlayPause();'>Play</button>
<button id='stop-button' class='stop' title='stop' onclick='stopPlayer();'>Stop</button>
<button id='volume-inc-button' class='volume-plus' title='increase volume' onclick='changeVolume("+");'>Increase volume</button>
<button id='volume-dec-button' class='volume-minus' title='decrease volume' onclick='changeVolume("-");'>Decrease volume</button>
<button id='mute-button' class='mute' title='mute' onclick='toggleMute("true");'>Mute</button>
</div>
<div id='media-play-list'>
<h2>Play list</h2>
<ul id='play-list'>
<li><span class='play-item' onclick='loadVideo(http://www.youtube.com/myvideo);'>Fischer</span></li>
<li><span class='play-item' onclick='loadVideo("paddle-wheel.webm", "paddle-wheel.mp4");'>Paddle Steamer Wheel</span></li>
<li><span class='play-item' onclick='loadVideo("grass.webm", "grass.mp4");'>Grass</span></li>
</ul>
</div>
</div>
Of course it is possible. Just include the absolute path to your videos:
<video controls>
<source src=http://techslides.com/demos/sample-videos/small.webm type=video/webm>
<source src=http://techslides.com/demos/sample-videos/small.ogv type=video/ogg>
<source src=http://techslides.com/demos/sample-videos/small.mp4 type=video/mp4>
<source src=http://techslides.com/demos/sample-videos/small.3gp type=video/3gp>
</video>
The gist is to organize your file in the correct order, user browser will auto detect the supported file types and play it accordingly.
Read more #: http://techslides.com/sample-webm-ogg-and-mp4-video-files-for-html5/.
And I believe you've read this: http://www.w3schools.com/tags/tag_video.asp ?
Related
I am using Video.js to play a video on my site and would like to disable the default double click to full screen behaviour.
I found this in the docs but not sure how to implement it. I have tried placing the suggested code in my main.js file but I guess I need to do something else as that doesn't work?
This is the simplified video.js code I'm using:
<!DOCTYPE html>
<html>
<head>
<link href="https://vjs.zencdn.net/7.8.2/video-js.css" rel="stylesheet" />
<!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->
<script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>
</head>
<body>
<video
id="my-video"
class="video-js"
controls
preload="auto"
width="640"
height="264"
poster="MY_VIDEO_POSTER.jpg"
data-setup="{}"
>
<source src="MY_VIDEO.mp4" type="video/mp4" />
<source src="MY_VIDEO.webm" type="video/webm" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>
<script src="https://vjs.zencdn.net/7.8.2/video.js"></script>
</body>
</html>
As you're using data-setup to init the player, then add it to the JSON string:
data-setup='{"userActions": {"doubleClick": false }}'
I am using video.js for my video gallery. I tried video.js but I am getting the following error message.
Uncaught TypeError: $(...).lightGallery is not a function
My code:
<html>
<head>
<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
</head>
<body>
<!-- Hidden video div -->
<div style="display:none;" id="video1">
<video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
<source src="videos/test1.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</div>
<div style="display:none;" id="video2">
<video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
<source src="videos/test2.mp4" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</div>
<!-- data-src should not be provided when you use html5 videos -->
<ul id="video-gallery">
<li data-poster="video-poster1.jpg" data-sub-html="video caption1" data-html="#video1" >
<img src="1.jpg" />
</li>
<li data-poster="video-poster2.jpg" data-sub-html="video caption2" data-html="#video2" >
<img src="2.jpg" />
</li>
...
</ul>
</body>
<script>
$('#video-gallery').lightGallery({
videojs: true
});
</script>
</html>
please suggest the solution.
You seem to be missing the script tag for lightgallery
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.4/js/lightgallery.min.js"></script>
$(document).ready(function() {
$('#video-gallery').lightGallery({
videojs: true
});
});
Strange thing, but the current version could be initialized only this way (typical JQuery syntax doesn't work):
lightGallery($('#video-thumbnails')[0], {
download: false,
//other options
});
There is even opened Issue on Github: https://github.com/sachinchoolur/lightgallery.js/issues/42
Is there anyway or javascript class or function that I can used to get the duration on the embed file?
I know we can do it like this
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()" type="button">Get video length</button><br>
<video id="myVideo" width="320" height="176" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<script>
var vid = document.getElementById("myVideo");
function myFunction() {
alert(vid.duration);
}
</script>
<p>Video courtesy of Big Buck Bunny.</p>
</body>
</html>
it only works on some supported browsers but not in ie8 below. Can anyone guide me how can I get the duration of the embed files? that can work on any crossbrowsers? or do I need to make a parser? please help thank you.
I am trying to have a page with embedded video that dynamically will change the source when a link below the video frame is clicked. The source videos are on my host server.
i.e. this pic illustrates it:
I came across this page, which seems to have the answer, but I tried it and it didn't work. Following the example, I pasted the css & javascript in the and the necessary html in the body. I updated all the references to my urls and tried to keep file names the same as the example for testing.
Below is what I tried.
Can someone point out my errors, or provide a more elegant way of doing this? Basically dynamically change embedded video when link is clicked and the video work in all the typical browsers, and most devices.
This is for a wordpress site, using JW Player for wordpress, (my error) instead I found this script/code is actually for Video.js
It loads the pre image but doesn't play.
As a test I tried this and it does play single video properly:
<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>
The 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");
// hide the current loaded poster
$("img.vjs-poster").hide();
$vid_obj.ready(function() {
// hide the video UI
$("#div_video_html5_api").hide();
// and stop it from playing
$vid_obj.pause();
// assign the targeted videos to the source nodes
$("video:nth-child(1)").attr("src",$content_path+$target+".mp4");
$("video:nth-child(1)").attr("src",$content_path+$target+".ogv");
$("video:nth-child(1)").attr("src",$content_path+$target+".webm");
// replace the poster source
$("img.vjs-poster").attr("src",$content_path+$target+".png").show();
// reset the UI states
$(".vjs-big-play-button").show();
$("#div_video").removeClass("vjs-playing").addClass("vjs-paused");
// load the new sources
$vid_obj.load();
$("#div_video_html5_api").show();
});
});
$("input[rel='01']").click();
</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 1st video loads but no video, error is
"No video with supported format and MIME type found"
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>
Result the 1st video loads but not the other linked videos.
names of the videos/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, testvid_03.webm, testvid_03.png
I have tried this both in wordpress page and html page the results are the same.
I'm not sure even if this script will do what I want?
Have you tried doing it via JW Player's JavaScript API? From what I gather you can load a playlist and invoke a function that will play a video at a certain index:
playlistItem(index)
Start playback of the playlist item at the specified index.
I suppose its a common question, but none of the tutorials and post I've seen have helped me so far. What I want its a sound to play whenever the cursor is over a menu image which is also a link. There's already another instruction in the onmouseover event for the image to flicker, but I've read that the event can have multiple instructions. Here's the code
(sorry if it looks messy)
<html>
<head>
<script type="text/javascript">
var sonido=document.getElementById("neonclip");
</script>
</head>
<body>
<audio id="neonclip">
<source src="http://www.eleyte.net/portafolio/neon.mp3" type="audio/mp3"/>
</audio>
<div style="text-align: center; margin-top: 130px;">
<a href="pagelink">
<img onmouseover="this.src='img2';
sonido.play(document.getElementById('neonclip'))
onmouseout="this.src='img1'"src="img1"/> </a>
</div>
</body>
</html>
I did this following an example but it didn't work. I know it'll have problems in firefox because it doesnt support mp3 format, but thats another story. Thanks in advance!
Just user below two format to play sound in all browsers.
<audio preload id="neonclip">
<source src="sounds/dingdong/57718^DingDong.mp3" type="audio/mpeg">
<source src="sounds/dingdong/dingdong.ogg" type="audio/ogg">
</audio>
And to play the sound try this
<a href="pagelink">
<img onmouseover="this.src='img2'; document.getElementById('neonclip').play()" onmouseout="this.src='img1'"src="img1"/> </a>