How to set the thumbnail image on HTML5 video?
Add poster="placeholder.png"
to the video tag.
<video width="470" height="255" poster="placeholder.png" controls>
<source src="video.mp4" type="video/mp4">
<source src="video.ogg" type="video/ogg">
<source src="video.webm" type="video/webm">
<object data="video.mp4" width="470" height="255">
<embed src="video.swf" width="470" height="255">
</object>
</video>
Does that work?
video html5: Is it possible to display thumbnail from video on a specific time?
Maybe this helps: (I have not tested it. Also you might be able to set the "poster" attribute of the video to the src of the image object. Just try it. =) )
<video width="320" height="240" controls id="video">
<source src="video.mp4" type="video/mp4">
</video>
$(document).ready(function() {
var time = 15;
var scale = 1;
var video_obj = null;
document.getElementById('video').addEventListener('loadedmetadata', function() {
this.currentTime = time;
video_obj = this;
}, false);
document.getElementById('video').addEventListener('loadeddata', function() {
var video = document.getElementById('video');
var canvas = document.createElement("canvas");
canvas.width = video.videoWidth * scale;
canvas.height = video.videoHeight * scale;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
var img = document.createElement("img");
img.src = canvas.toDataURL();
$('#thumbnail').append(img);
video_obj.currentTime = 0;
}, false);
});
Source 1
Source 2
HTML5 Video poster attribute in Safari and Chrome
It seems that WebKit strips the attribute as soon as the video is fethced, because iOS 3.x for Iphone and Ipad has a serious bug where it is not possible to play the video at all when there is a poster attribute specified. This was fixed in iOS 4, but the workaround still stays, even in Safari 5...There are a lot of users who didn't upgrade to iOS 4 yet, so no luck with the poster...
I'm going to try and position the image absolutely over the video using Javascript, and removing it when the video is played - that seems like the best solution...
Related Topics
Value of Type 'string' Has No Member 'stringbytrimmingcharactersinset'
In What Format Is This Date String
Remove Duplicate Structs in Array Based on Struct Property in Swift
How to Set UIactivityviewcontroller Gmail Share Subject Different Than Body
Screenshot on Swift Programmatically
How to Convert Cgpoint in Nsvalue in Swift
Cfbundledocumenttype Is Not Working in Myproject-Info.Plist File
Googlemap API Gives Wrong Coordinates for Direction Between Two Points
How to Animate a Nslayoutconstraint in Swift
How to Loop Through and Get All The Keys of The Nested Nodes in Firebase
Force UIsplitviewcontroller to Always Show Master (Only) in Landscape (On iPhone 6 Plus)
Firebase Database Not Equal Request - Alternative Solution (For iOS)
Is There an iOS API for Accessing Call Logs
Retina Display Vs Normal Display Color Difference