Как воспроизвести аудиопоток m3u в приложении для iOS
Я пытаюсь создать радио приложение для iOS / iPhone, используя Xcode 4.5.2.
Я хотел стрим @http://xx.xxxxxxx.com/8111/radio.m3u» с воспроизведением, паузой, регулировкой громкости и возможностью воспроизведения на фоне / многозадачность.
мы добавили,AVFoundation
Mediaplayer
а такжеAudioToolBox
рамки до сих пор. Я'мы добавили объекты воспроизведения, паузы и слайдера в xib.
ViewController.h
@interface ViewController : UIViewController
@property (strong,nonatomic) MPMoviePlayerController *myPlayer;
@property (weak, nonatomic) IBOutlet UISlider *myslider;
- (IBAction)playButtonPressed;
- (IBAction)myslider:(id)sender;
@end
ViewController.m
#import "ViewController.h"
#import
@interface ViewController ()
{
UISlider *volumeSlider;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
UIBackgroundTaskIdentifier newTaskId = UIBackgroundTaskInvalid;
newTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:NULL];
}
- (IBAction)playButtonPressed;
{
NSString *urlAddress = @"http://xxxxxxx.com/8111/listen.m3u";
NSURL *url = [NSURL URLWithString:urlAddress];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]initWithContentURL:url];
player.movieSourceType = MPMovieSourceTypeStreaming;
[player prepareToPlay];
self.myPlayer = player;
[self.view addSubview:self.myPlayer.view];
[self.myPlayer play];
}
- (IBAction)stopButtonPressed;
{
[self.myPlayer stop];
}
- (IBAction)myslider:(id)sender
{
MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame: CGRectMake(10, 10, 200, 40)];
[volumeSlider addSubview:volumeView];
[volumeView sizeToFit];
}