【问题标题】:iphone: video playing with sound only.video is not being viewediphone:仅播放有声音的视频。未查看视频
【发布时间】:2011-07-06 06:37:55
【问题描述】:

这是我播放视频的功能。但它只播放声音,没有观看视频

  -(void)playMovieAtURL:(NSString *)moviePath
    {   
        NSURL *movieURL=[NSURL URLWithString:moviePath];

        MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

        NSLog(@"url : %@",movieURL);

        [player setControlStyle:MPMovieControlStyleDefault];

        [player setScalingMode:MPMovieScalingModeAspectFit];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDidExitFullscreen:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];

        [[player view]setFrame:[[self view]bounds]];
        [[self view] addSubview:[player view]];

        [player play];

    }

【问题讨论】:

    标签: iphone objective-c cocoa-touch ios4 mpmovieplayer


    【解决方案1】:

    MPMoviePlayerController 只是一个电影播放器​​,如果有意义的话,它实际上并不处理电影的显示。如果您需要将视频嵌入到您自己的视图层次结构中,您应该只使用 MPMoviePlayerController。听起来您不需要这样做,因为您正在全屏播放并且提到了自定义控件,因此请尝试使用MPMoviePlayerViewController。它可以完成从 URL 加载电影并使用本机控件显示视频所需的一切。只需使用您的 URL 实例化 MPMoviePlayerViewController 并将其呈现为模态视图,即

    MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL urlWithString:moviePath]];
    [self presentModalViewController:player];
    [player release];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      相关资源
      最近更新 更多