Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

I Can't generate Thumbnail image by using below code.

$
0
0

help me. I want to get thumbnail image from mp4 video url:

var win = Ti.UI.createWindow({backgroundColor:'white'});

var video_full_path = "http://sample.mp4";

var thumbnail_button = Titanium.UI.createButton({ title: 'Gen Thumbnail', top: 200, height:32, width:160 });

thumbnail_button.addEventListener ('click', function() { var recent_vid = Titanium.Media.createVideoPlayer({ contentURL: video_full_path });

alert("File: " + video_full_path); 
alert("Duration: " + recent_vid.duration); 
alert("Generating thumbnail..."); 
//var thumbnail = recent_vid.thumbnailImageAtTime (2, Titanium.Media.VIDEO_TIME_OPTION_EXACT); 
var thumbnail = recent_vid.thumbnailImageAtTime(2, Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME);
alert("Done generating thumbnail: "+thumbnail); 
win.add(Ti.UI.createImageView({
    image:thumbnail,
    bottom:10,
    height:200,
    width:300
}));

}); win.add (thumbnail_button);

var play_button = Titanium.UI.createButton({ title: 'Play Video', top: 100, height:32, width:160 });

play_button.addEventListener ('click', function() { var recent_vid = Titanium.Media.createVideoPlayer({ contentURL: video_full_path,

}); 

alert("Playing " + video_full_path); 
alert("Duration: " + recent_vid.duration);
win.add(recent_vid);
recent_vid.play(); 

});

win.add (play_button); win.open();


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>