-->

我可以发挥在iPad模拟器的FLV?(Can I play an FLV on the iPad S

2019-10-29 17:55发布

I am trying to create a simple app for the iPad that with play an FLV when you click a button. I am using the code from http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#VIDEO-USE_THE_MEDIA_PLAYER_FRAMEWORK_FOR_VIDEO_PLAYBACK as a reference. Here is the code for my click event

-(IBAction) btnPlayVideoClick:(id) sender { 
 NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"flv"];    

 MPMoviePlayerController* myMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
 myMovie.scalingMode = MPMovieScalingModeAspectFill;


 // Register for the playback finished notification.

 [[NSNotificationCenter defaultCenter] addObserver:self
            selector: @selector(myMovieFinishedCallback:)
             name:MPMoviePlayerPlaybackDidFinishNotification
              object:myMovie];
 [myMovie play];

}


-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{
    MPMoviePlayerController* theMovie=[aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification 
                                                  object:theMovie]; 

    // Release the movie instance created in playMovieAtURL
    [theMovie release]; 
}

I am able to successfully compile and run the app, but when I click the button the app just exits with no error message or any activity at all. Is there something that I am doing wrong, or is there some reason I cannot play an FLV using the simulator. I can't test on a real device yet because I am waiting for approval to get my dev license.

Thanks,

Mike

Answer 1:

iOS设备不具备闪光灯,所以你不能播放任何Flash视频。



Answer 2:

iOS不具备正确的编解码器来播放FLV。 它需要重新编码为.MP4​​或.mov文件。 东西的iOS能真正发挥。 我还没有试过读你的代码,看看它是否有效。这就是我发现为“不正确”的第一件事。



Answer 3:

看到你已经解决了闪存问题下一个问题我看到的是,你似乎没有在任何地方把播放器视图。 你要么需要把视图某处的层次或设定myPlayer.fullscreen = TRUE; 不知道更多你的看法,我不能给你建议的嵌入,但检查出的苹果示例代码位,看看他们是如何做到这一点: http://developer.apple.com/iphone/library/documentation/mediaplayer /reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html#//apple_ref/doc/uid/TP40006953-CH3-DontLinkElementID_1



文章来源: Can I play an FLV on the iPad Simulator?