我想通过播放,暂停,音量控制来播放@“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;@endVIEwController.m#import "VIEwController.h"#import <MediaPlayer/MediaPlayer.h>@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]; }解决方法 实现这一目标有两种方法.
>您可以直接在UIWebVIEw中加载URL,它将正确.>您也可以使用MPMovIEPlayerController.
总结以上是内存溢出为你收集整理的如何在iOS应用程序中播放m3u音频流全部内容,希望文章能够帮你解决如何在iOS应用程序中播放m3u音频流所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)