簡體   English   中英

未顯示電影,出現黑屏

[英]Not Showing Movie, Black Screen Appears

我的電影播放器​​正在播放,但不播放任何視頻。 它只播放聲音。

我的代碼如下:

    self.moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:nil];

    self.moviePlayer.view.frame=CGRectMake(10, (self.view.frame.size.height-200-64)/2, 300, 200);

    [self.moviePlayer setControlStyle:MPMovieControlStyleDefault];

    [self.moviePlayer setShouldAutoplay:YES];
    self.moviePlayer.allowsAirPlay = YES;
    self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;

    self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
    self.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
     [self.moviePlayer setContentURL:[NSURL URLWithString:AttachmentUrl]];
    [self.view addSubview:self.moviePlayer.view];

    self.moviePlayer.fullscreen=YES;
    [self.moviePlayer prepareToPlay];

    [self.moviePlayer play];


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

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(movieloadStateHandler:)
                                                 name:MPMoviePlayerLoadStateDidChangeNotification
                                               object:nil];

請建議我我需要做什么。

我的經驗是,最好使用: MPMoviePlayerViewController

例如:

MPMoviePlayerViewController *mvPlayerController = [[MPMoviePlayerViewController alloc]
                               initWithContentURL:[NSURL URLWithString:AttachmentUrl]];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM