如何在iphone上播放实时视频流?

时间:2015-01-30 12:23:55

标签: ios iphone

我想在我的应用上播放实时视频流,但我找不到任何解决方案。这是我想在我的iPhone应用程序上播放的视频流的URL。 http://live.cricket-365.pw/embed1.php 有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

使用MPMoviePlayerController

导入MediaPlayer框架 ,然后在ViewController.h中或.m

ViewController.h

中的

@interface ViewController:UIViewController< MPMediaPickerControllerDelegate >

@property(强,非原子)MPMoviePlayerController * moviePlayerController;

ViewController.m

中的

viewDidLoad 或您想要的地方尝试此操作

NSURL * urlVideo = [NSURL URLWithString:@“在此输入您的网址”];

     _moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:urlVideo];

 if([[UIScreen mainScreen] bounds].size.width==320) //for iphone 4, 5
 {

     [_moviePlayerController.view setFrame : CGRectMake(0, _lblTitleVideo.bounds.size.height+120,320, 270)]; // tweak as needed
 }
if([[UIScreen mainScreen] bounds].size.width==375) //for iphone 6
{
  [_moviePlayerController.view setFrame : CGRectMake(0, _lblTitleVideo.bounds.size.height+120,375, 270)]; // tweak as needed
}
if([[UIScreen mainScreen] bounds].size.width==414) //for iphone 6 plus
{
   [_moviePlayerController.view setFrame : CGRectMake(0, _lblTitleVideo.bounds.size.height+120,414, 270)]; // tweak as needed
}

 _moviePlayerController.view.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
     [self.view addSubview:_moviePlayerController.view];


     _moviePlayerController.fullscreen = YES;
     [_moviePlayerController play];