2014-09-01 100 views
1

有人可以帮我解决这个问题。无法在iOS中播放3gp文件

Apple文档说我们可以使用iOS媒体播放器播放3gp媒体文件。 我试过MPMovieControllerAVPlayer但我无法玩。

+0

在哪个文件你看到3gp? – 2014-09-01 06:45:36

+0

支持3gp,但要确保你的3gp符合苹果标准。 (分辨率和fps等) – sleepwalkerfx 2014-09-01 06:52:28

回答

0

我使用系统AudioToolbox.framework在我的简单游戏中播放声音。我加入这个静态函数共同MyGame类:

+ (SystemSoundID) createSoundID: (NSString*)name 
{ 
    NSString *path = [NSString stringWithFormat: @"%@/%@", 
        [[NSBundle mainBundle] resourcePath], name]; 


    NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO]; 
    SystemSoundID soundID; 
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID); 
    return soundID; 
} 

我添加了“Morse.aiff”文件,项目资源和(任何)类的初始化有以下初始化它:

self.mySound = [MyGame createSoundID: @"Morse.aiff"]; 

而且然后我打的声音,这个调用:

AudioServicesPlaySystemSound(mySound); 

另外,不要忘记导入AudioServices.h文件。

此音频工具箱还可以播放不同的声音格式。

希望它可以帮助你..