开发者

How to apply conditions to play video in full screen and to play in a certain frame

I am playing a video by default in full screen according to this:

Play video by default in full screen

But using this code minimize control is missing.

My exact requirment is that:

As the view will load a video will play by default in full screen and when it will be minimize it should be play in a certain frame. And when it will end I wa开发者_JS百科nt to write some code, but What condition will be apply to check to whether the video is finish/end?

Plz help me out.

Thanks.


when ever you alloc your moviePlayer object add bellow notification:

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

so when your video will finish playing or you will finish it by done bellow method will be called:

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


You need to register for the notification as below

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


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

and then implement the messages as follows:

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


hi use this its work fine

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜