【问题标题】:I Want the Video file to Play repeatedly in my application an I am using the MPMoviePlayerController to play the video file我希望视频文件在我的应用程序中重复播放,我正在使用 MPMoviePlayerController 播放视频文件
【发布时间】:2011-03-14 10:42:51
【问题描述】:

各位朋友, 我希望视频文件在我的应用程序中重复播放,我使用以下代码播放视频文件

NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:tempurl]];
player.view.frame = CGRectMake(0, 0, 867, 1008);
player.scalingMode = MPMovieScalingModeFill;
[self.view addSubview:player.view];
[player play];

我可以有一个可以在视频文件播放结束时发出警报的 Delegate 方法吗 提前谢谢你

【问题讨论】:

    标签: iphone iphone-sdk-3.0 mpmovieplayercontroller mpmoviewcontroller


    【解决方案1】:

    您可以使用属性“repeatMode”并将其设置为 MPMovieRepeatModeOne

    //Determines how the movie player repeats the playback of the movie.
    
    
    @property(nonatomic) MPMovieRepeatMode repeatMode
    
    //Discussion The default value of this property is MPMovieRepeatModeNone. 
    
       // For a list of available repeat modes, see “MPMovieRepeatMode.”
    
    // Availability Available in iOS 3.2 and later.Declared In MPMoviePlayerController.h
    
    NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:tempurl]];
    
    player.view.frame = CGRectMake(0, 0, 867, 1008);
    
    player.scalingMode = MPMovieScalingModeFill;
    
    player.repeatMode = MPMovieRepeatModeOne;
    
    [self.view addSubview:player.view];
    
    [player play];
    

    【讨论】:

    • 我可以隐藏视频进度条吗?
    • 是的,您可以使用属性 controlStyle 隐藏并将其设置为 MPMovieControlStyleNone
    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 2011-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多