zoukankan      html  css  js  c++  java
  • (原创)IOS播放视频

    //创建播放器并播放视频。
    -(void) playMovie{
        NSString* videoPath = [[Globals getResourceManager] loadVideo:@"abcSong"];
        player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:videoPath]];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:)  name:MPMoviePlayerPlaybackDidFinishNotification object:player];    
     
        player.controlStyle = MPMovieControlStyleFullscreen;
        player.view.frame = [Globals getScreenRect];
        player.initialPlaybackTime = -1;
        [self.view addSubview:player.view];
        player.backgroundColor = [UIColor blackColor];
        player.useApplicationAudioSession = NO;        
        player.movieControlMode = MPMovieControlModeHidden;
        player.scalingMode = MPMovieScalingModeAspectFit;   
        
        [player play];
    //当视频播放结束释放资源。
    -(void) movieFinishedCallback:(NSNotification*) aNotification{
         [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
        [player stop];
        [player.view removeFromSuperview];
        [player release];
        player = nil;
    }
  • 相关阅读:
    设计模式之《工厂方法》
    设计模式之 《简单工厂》
    fegin 调用源码分析
    ajax上传预览
    ajax小应用
    ajax执行流程1
    ajax异步post方法
    ajax get异步方法
    js ajax请求流程
    form表单提交
  • 原文地址:https://www.cnblogs.com/mrhgw/p/2601029.html
Copyright © 2011-2022 走看看