代码之家  ›  专栏  ›  技术社区  ›  mclark1129

我可以在ipad模拟器上玩flv吗?

  •  0
  • mclark1129  · 技术社区  · 14 年前

    我正在尝试为iPad创建一个简单的应用程序,当你点击一个按钮时,它会播放一个flv。我使用的代码来自 http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#VIDEO-USE_THE_MEDIA_PLAYER_FRAMEWORK_FOR_VIDEO_PLAYBACK 作为参考。这是我点击事件的代码

    -(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]; 
    }
    

    我能够成功地编译和运行应用程序,但是当我单击按钮时,应用程序就退出了,没有任何错误消息或任何活动。有什么我做错了,或者有什么原因我不能用模拟器来玩FLV。我还不能在真正的设备上测试,因为我正在等待获得开发许可证的批准。

    谢谢,

    迈克

    3 回复  |  直到 14 年前
        1
  •  6
  •   Jamison Dance    14 年前

    iOS设备没有Flash,因此无法播放任何Flash视频。

        2
  •  1
  •   Dustin    14 年前

    iOS没有正确的编解码器来播放FLV。它需要重新编码为.mp4或.mov文件。iOS可以实际播放的内容。我没试着读你的代码看它是否有效。这只是我注意到的第一件“不正确”的事情。

        3
  •  0
  •   Jeremy    14 年前

    既然你已经解决了flash的问题,那么我看到的下一个问题是你似乎没有把播放器的视图放在任何地方。您要么需要将视图放在层次结构中的某个位置,要么将myplayer.fullscreen设置为true; 在不了解更多关于您的视图的信息的情况下,我不能给您关于嵌入它的建议,但请从Apple中查看这段示例代码,以了解它们是如何做到的: http://developer.apple.com/iphone/library/documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html#//apple_ref/doc/uid/TP40006953-CH3-DontLinkElementID_1