无法使用AVPlayer播放.wav文件 [英] Unable to play .wav file Using AVPlayer

查看:234
本文介绍了无法使用AVPlayer播放.wav文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些wav文件,它们与MPMoviePlayer完全兼容.但不能与AVPlayer一起使用.由于某些原因,我将播放器更改为AVPlayer.但是在实施之后,我发现我的某些音频文件无法与AVPlayer一起使用.我使用了AVPlayer的apples示例代码.任何建议,将不胜感激.

I have some wav files and they completely working with MPMoviePlayer. but not working with AVPlayer. For some reason I have changed my player to AVPlayer. But after implementation I found that some of my audio files are not working with AVPlayer.I have used apples sample code of AVPlayer. Any suggestion would be appreciated.

推荐答案

其他格式还能用吗?也许是编码问题.

Does other format work ? Perhaps it's a coding problem.

无论如何.如果您的WAV文件没有问题,请将其导入iTunes,将其转换一次(右键单击该文件到库中),然后将转换后的文件转换回wav(相同方法).然后,您应该拥有一个与iPhone兼容的WAV文件.

Anyway. If your WAV files are ok, import them into iTunes, convert them once (right click on the file into the library), and convert the converted one back to wav (same method). You should then have an iPhone compatible WAV file.

如果这不起作用,那应该是编码问题:-)

If that does not work, that should be a coding problem :-)

尝试:

NSString* path = [[NSBundle mainBundle] pathForResource:soundfileName ofType:fileType];
if ([[NSFileManager defaultManager] fileExistsAtPath:path] == NO) NSLog (@"No file");

AVPlayer* player = [AVPlayer playerWithURL:[NSURL fileURLWithPath:path]];
[player play];    

这篇关于无法使用AVPlayer播放.wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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