Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private ImageView1 As ImageView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.LoadLayout("1")
NavControl.ShowPage(Page1)
Dim no As NativeObject = Me
Dim bmp As Bitmap = no.RunMethod("thumbnail:", Array(File.Combine(File.DirAssets, "Video.mp4")))
ImageView1.Bitmap = bmp
End Sub
#if objc
@import CoreMedia;
@import AVFoundation;
- (UIImage*)thumbnail:(NSString*) FilePath {
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:FilePath] options:nil];
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
gen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600);
NSError *error = nil;
CMTime actualTime;
CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
CGImageRelease(image);
return thumb;
}
#end if