These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:11 pm Advanced search

HTML5 Video poster

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

HTML5 Video poster

Postby Graveto » Tue Jul 06, 2010 11:28 am

Hi,

does anyone know how to change the poster of a html5 video onClick?

This is how I change the source:

Code: Select all
function loadAnotherVideo() {
  var video = document.getElementsByTagName('video')[0];
  var sources = video.getElementsByTagName('source');
  sources[0].src = 'video2.ogv';
  video.load();
}

Is there a similar way to change the poster?

Thanks.
Graveto
Graveto
<h6>
 
Posts: 8
Joined: Tue Jul 06, 2010 11:23 am

Postby Graveto » Tue Jul 06, 2010 11:45 am

Oops. This was easy!
Here is the solution:

Code: Select all
video.setAttribute('poster', 'yourNewPoster.jpg');
Graveto
<h6>
 
Posts: 8
Joined: Tue Jul 06, 2010 11:23 am

Postby zcorpan » Tue Jul 06, 2010 12:26 pm

The easier way is
Code: Select all
video.poster = 'yourNewPoster.jpg';

:)
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests