1
我試圖以編程方式從MPMoviePlayerController視頻的當前幀創建一個圖像。我使用renderInContext呼籲玩家的view.layer但創建的圖像是全黑與視頻播放器的控制,但我期待看到該視頻的當前幀在MPMoviePlayerController上調用renderInContext
我的代碼(http://pastie.org/1020066)
UIGraphicsBeginImageContext(moviePlayer.view.bounds.size);
[moviePlayer.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// I also tried this code (same results)
// moviePlayer is a subview of videoView (UIView object)
UIGraphicsBeginImageContext(videoView.bounds.size);
[videoView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();