Can I play an FLV on the iPad Simulator?

六月ゝ 毕业季﹏ 提交于 2019-12-12 01:30:06

问题


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


回答1:


iOS devices do not have Flash, so you can't play any Flash video.




回答2:


iOS doesn't have the correct codecs to play an FLV. It needs to be reencoded as a .mp4 or .mov file. Something that iOS can actually play. I haven't tried to read your code to see if it's valid.. this is just the first thing I notice as being "incorrect".




回答3:


Seeing that you already addressed the Flash issue the next issue I see is that you don't seem to be putting the player view anywhere. You either need to put the view somewhere in your hierarchy or set myPlayer.fullscreen = TRUE; Without knowing more about your views I can't give you advice on embedding it but check out this bit of sample code from Apple to see how they do it: http://developer.apple.com/iphone/library/documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html#//apple_ref/doc/uid/TP40006953-CH3-DontLinkElementID_1



来源:https://stackoverflow.com/questions/3345601/can-i-play-an-flv-on-the-ipad-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!