2016-05-10 8 views
0

私はiOSにアンププレーヤーを内蔵していますので、mp4ビデオを細かく再生していますが、埋め込みビデオを再生したいと思います。それではどうしたらいいのですか? MPMoviePlayerを使用することができない場合は、他の解決方法もあれば、kmsを与えてください。iOSのURLを使用して埋め込みビデオを再生するには

おかげ

答えて

0

あなたはMPMoviePlayerControllerを使用してmp4ファイルを再生することができます。何かのように、

あなたviewController.hファイル

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

@interface ViewController : UIViewController 
{ 
AVAudioPlayer *audioPlayer; 
MPMoviePlayerViewController *moviePlayer; 

} 
-(IBAction)playAudio:(id)sender; 
-(IBAction)playVideo:(id)sender; 
@end 

あなたviewController.mファイルを使用すると、これが役立つの詳細についてthis tutorial

希望を参照することができ

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 
-(IBAction)playAudio:(id)sender{ 
NSString *path = [[NSBundle mainBundle] 
pathForResource:@"audioTest" ofType:@"mp3"]; 
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL: 
[NSURL fileURLWithPath:path] error:NULL]; 
[audioPlayer play]; 
} 
-(IBAction)playVideo:(id)sender{ 
    NSString *path = [[NSBundle mainBundle]pathForResource: 
@"videoTest" ofType:@"mov"]; 
moviePlayer = [[MPMoviePlayerViewController 
alloc]initWithContentURL:[NSURL fileURLWithPath:path]]; 
[self presentModalViewController:moviePlayer animated:NO]; 
} 
@end 

、のようにする必要があります:)

+0

はい、私はmpmoviePlayer bでmp4ビデオを再生できることを知っていましたここで私はそれを望んでいない。私は埋め込まれたビデオのURLを再生したい。 –

+0

埋め込みビデオのURLはどういう意味ですか? – Lion

+0

youtube video(「https://m.youtube.com/watch?v=J6vIS8jb6Fs」のように) –

関連する問題