Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 video player: dynamically loading videos

So, using a HTML 5 compliant video player, (like Video JS) how would one go about loading a video dynamically, without having to reload the entire page? Imagine, a list of links (something like a playlist), and each link points to a video. When clicking the link, I want to load the selected video into player.

Currently, I'm using an Iframe that holds the video player, so basically a I pass a variable on to the Iframe, and reload it. I don't think this is ideal, for a few reasons; it doesn't allow the video to go full screen, the Back button moves the Iframe back not just the main page, plus, it's an Iframe. I'd rather avoid this.

Ideas? Thanks!

like image 750
Benjamin Allison Avatar asked Aug 30 '10 16:08

Benjamin Allison


People also ask

What is Videojs?

Video.js is a web video player built from the ground up for an HTML5 world. It supports HTML5 video and modern streaming formats, as well as YouTube, Vimeo, and even Flash (through plugins, more on that later). It supports video playback on desktop and mobile devices.

Is HTML5 video good?

HTML5 video players are garnering wide popularity owing to their exclusive features and solutions that not only simplifies cross device, browser and platform compatibility but also ensures easy sharing, customization, modifying settings and controls for the users and many more.

How do HTML5 video players work?

How it Works. HTML5 video works by allowing the person uploading the video to embed it directly into a web page. It works in a variety of internet browsers, including Internet Explorer 9+, Firefox, Opera, Chrome and Safari. Unfortunately, the technology is not compatible with Internet Explorer 8 and earlier versions.

Can MP4 play on HTML5?

Yes, with our WordPress gallery plugin Wonder Gallery, you only need to provide one mp4 format to play in all web browsers and devices. In iPhone, iPad, Android, Chrome, Safari, Firefox, Opera, IE 10 and above, the gallery plugin will use HTML5 to play the mp4 video.


1 Answers

Came up with a simple solution. Here's the script; throw this in the head:

function vidSwap(vidURL) {
var myVideo = document.getElementsByTagName('video')[0];
myVideo.src = vidURL;
myVideo.load();
myVideo.play();
}

And then the HREF will call the function:

<a href="#" onClick="javascript:vidSwap('myMovie.m4v'); return false;">Link</a>
like image 82
Benjamin Allison Avatar answered Oct 08 '22 20:10

Benjamin Allison