2013-04-10 157 views

回答

3

您可以使用MPMovieplayerviewcontroller &它也看起来像iPhone的默认播放器。

这里是我的回答:how to play live streaming from url for a camera that broadcasting live

FOR BACKGROUND:对于下面的viewDidLoad方法行后台播放写 -

NSError *setCategoryErr = nil; 
    NSError *activationErr = nil; 
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr]; 
    [[AVAudioSession sharedInstance] setActive: YES error: &activationErr]; 
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 
    UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid; 
    newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL]; 

,也使您的info.plist像下面的图像的小变化: enter image description here

+0

谢谢@Vishal + 1为贵 “的直播。” :) – TonyMkenu 2013-04-12 09:14:09

0

写下面给出代码didFinishLaunchingWithOptions

AVAudioSession *audioSession = [AVAudioSession sharedInstance]; 
NSError *setCategoryError = nil; 

BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; 
if (!success) { NSLog(@"Error"); } else {NSLog(@"Success");} 


NSError *activationError = nil; 
success = [audioSession setActive:YES error:&activationError]; 
if (!success) { NSLog(@"Error"); } else {NSLog(@"Success");}