我怎样才能加入的音频播放器在iPhone应用程序 [英] How can I Add Audio Player in iphone App

查看:172
本文介绍了我怎样才能加入的音频播放器在iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要添加音频播放器在我的app.I有没有关于它的想法。
我想也播放歌曲和播放列表制作...我怎么能这样做呢?

I want to add audio player in my app.I have no idea about it. I want to play songs and make playlist also...how can i do this?

推荐答案

做如下图所示。

#import <AVFoundation/AVFoundation.h>

NSString *musicFilePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mp3"];
NSURL *musicURL = [[NSURL alloc] initFileURLWithPath:musicFilePath];

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:musicURL error:nil];
[player prepareToPlay];
[player play];

这篇关于我怎样才能加入的音频播放器在iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆