2013-02-18 70 views
-3

我想在我的iOS應用中播放視頻。該視頻將從網上下載。如何在iOS應用程序中通過網絡播放視頻?

+0

你看看教程.. http://mobile.tutsplus.com/tutorials/iphone/mediaplayer-framework_mpmovieplayercontroller_ios4/ http://stackoverflow.com/questions/7001716/need-a-tutorial-for-ios-to-play-video-files-in-my- – 2013-02-18 06:48:22

回答

0

這可以幫助

#import <UIKit/UIKit.h> 
#import <MediaPlayer/MediaPlayer.h> 

@interface ViewController : UIViewController 

@property (nonatomic,strong)MPMoviePlayerController *moviePlayer; 

@end 



- (IBAction)playButtonEvent:(id)sender 
{ 
     NSURL *url=[[NSURL alloc]initWithString:@"http://www.jplayer.org/video/m4v/Big_Bunny_Trailer.M4v"]; 
      _moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:url]; 
      [_moviePlayer.view setFrame:CGRectMake(20, 100, 380, 150)]; 
     [self.view addSubview:_moviePlayer.view]; 

     _moviePlayer.fullscreen=YES; 
     _moviePlayer.allowsAirPlay=YES; 
     _moviePlayer.shouldAutoplay=YES; 
     _moviePlayer.controlStyle=MPMovieControlStyleEmbedded; 
} 
+0

此方法已棄用。請查看http://stackoverflow.com/a/31277658/6042879以獲取從服務器URL播放視頻的更新方式 – 2016-08-27 18:41:09

相關問題