2012-03-29 621 views

回答

4

尝试这样的:

NSString *path =[[NSString alloc] initWithString:@"http://stream.alayam.com/alayam/alayam/playlist.m3u8"]; 



NSURL *audioUrl=[NSURL URLWithString:path]; 

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:audioUrl]; 
[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(loadStateDidChange:)             name:MPMoviePlayerLoadStateDidChangeNotification 
              object:player]; 
if ([player respondsToSelector:@selector(loadState)]) 
{ 
    [player setControlStyle:MPMovieControlModeVolumeOnly]; 
    [player setFullscreen:YES]; 
    [player prepareToPlay]; 
} 
+0

的MPMoviePlayerController在iOS10贬值使用AVFoundation代替。 – 2016-10-16 22:25:45