2011-05-16 21 views
4

我玩視頻默認以全屏根據該玩法:如何申請條件,全屏播放視頻,並在一定的框架

Play video by default in full screen

但是使用這個代碼最小化控制失蹤。

我的確切需求量的是:

由於視圖加載視頻將默認以全屏播放,什麼時候會盡量減少它應該是在某一幀播放。 什麼時候結束我想寫一些代碼,但是什麼條件會適用於檢查視頻是否完成/結束?

PLZ幫助我。

謝謝。

+0

您是說了「減少管制」失蹤了。你試過哪種設備 - 以及安裝了哪個iOS版本? – Till 2011-05-17 10:24:42

+0

是的,如果我使用moviePlayer.controlStyle = MPMovieControlStyleFullscreen;那麼「最小化控制」就不存在了。我沒有檢查設備,在模擬器上我已經檢查並使用iOS 4.2謝謝 – 2011-05-17 11:09:39

+0

您鏈接的是哪個iOS SDK版本? – Till 2011-05-17 13:34:01

回答

0

您需要爲註冊通知如下

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(movieLoaded:) 
              name:MPMoviePlayerLoadStateDidChangeNotification 
              object:moviePlayer]; 


[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(moviePlayBackDidFinish:) 
              name:MPMoviePlayerPlaybackDidFinishNotification 
              object:moviePlayer]; 

,然後實現信息如下:

- (void)movieLoaded:(NSNotification*)notification 
- (void)moviePlayBackDidFinish:(NSNotification*)notification 
+0

我將在 - (void)movieLoaded:(NSNotification *)中寫入什麼代碼通知 – 2011-05-20 05:48:18

+0

@Archana MPMoviePlayerLoadStateDidChangeNotification對於您的任務不需要,忽略Hanuman答案的那部分內容。 – Till 2011-05-20 09:38:03

+0

@Till:好的..謝謝。 – 2011-05-20 11:23:10

1

當過你的Alloc您moviePlayer對象添加波紋管通知:

[[NSNotificationCenter defaultCenter] addObserver:self 
            selector:@selector(moviePlayBackDidFinish:) 
             name:MPMoviePlayerPlaybackDidFinishNotification 
             object:moviePlayer]; 

所以當你的視頻將完成播放或你會被做波紋管的方法完成它將被稱爲:

- (void)moviePlayBackDidFinish:(NSNotification*)notification 
{ 
// write your code here 
} 
+0

你可以使用命中測試,如果它在webview上播放.... – GameLoading 2012-02-02 13:11:28

0

在使用中這其做工精細

AVAsset *aset=[AVAsset assetWithURL:url]; 
AVPlayerItem *item=[[AVPlayerItem alloc]initWithAsset:aset]; 
play=[[AVPlayer alloc]initWithPlayerItem:item]; 
AVPlayerLayer *layer=[[AVPlayerLayer alloc]init]; 
layer.player=play;; 
layer.frame=CGRectMake(200, 250, 400, 250); 
[self.view.layer addSublayer:layer]; 

[play play];