Created
July 10, 2012 17:46
-
-
Save tzmartin/3085036 to your computer and use it in GitHub Desktop.
Create Thumbnail Image From Video File, Titanium Mobile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Create Thumbnail of Video File | |
This snippet captures a thumbnail JPG image, based on a frame @ 2 second time-lapse. | |
Titanium Mobile | |
*/ | |
var movie = Titanium.Media.createVideoPlayer({ | |
contentURL:FILENAME, | |
backgroundColor:'#111', | |
movieControlStyle: Titanium.Media.VIDEO_CONTROL_EMBEDDED, | |
scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FILL, | |
width:70, | |
height:70 | |
}); | |
var thumbBlob = movie.thumbnailImageAtTime(2.0, Titanium.Media.VIDEO_TIME_OPTION_EXACT); | |
var thumbFile = Titanium.Filesystem.applicationDataDirectory + "/media"+index+"_"+timestamp+".jpg"; | |
var thumb = Titanium.Filesystem.getFile(thumbFile); | |
thumb.write( thumbBlob ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Worked for Me. Try this....
videoPlayer.requestThumbnailImagesAtTimes([0],Titanium.Media.VIDEO_TIME_OPTION_NEAREST_KEYFRAME,setBackgroundImage);
//Callback for thumbnail image
function setBackgroundImage(e){
videoPlayer.backgroundImage = e.image;
//By e.image you get thumbnail image.
}