iOS7音频播放器控件

时间:2014-02-01 00:20:06

标签: ios cocoa-touch user-controls avaudioplayer

Apple是否向我们提供了一些音频控件,例如我们在控制中心和原生音乐应用中看到的标准音频控件?我们可以添加什么作为子视图?

或者我们是否必须创建自己的?

由于

2 个答案:

答案 0 :(得分:1)

不,他们没有。您必须自己创建所有这些控件。

然而,它们提供了几个在制作音乐播放应用程序时非常有用的框架。创建自己的按钮后,您可以将它们连接到您选择的音乐API。

如果你想控制设备内置的iPod,你需要Media Player Framework,但是如果你想创建更多自己的东西,你可能需要AVFoudation。< / p>

答案 1 :(得分:0)

尝试简单步骤:

第1步:#import <MediaPlayer/MediaPlayer.h>

第2步:在 .h 文件中设置委托UIViewController&lt; MPMediaPlayback&gt;

第3步:将此代码写在 .m 文件

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *vedioURL =[NSURL fileURLWithPath:fileLocation];
    MPMoviePlayerViewController *videoPlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:vedioURL];
    [self presentMoviePlayerViewControllerAnimated:videoPlayerView];
    [videoPlayerView.moviePlayer play];
}

-(void)endSeeking
{
    [self.navigationController popViewControllerAnimated:NO];
}

-(void)stop
{
    [self.navigationController popViewControllerAnimated:NO];
}
相关问题