2014-09-01 66 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文件。

此音頻工具箱還可以播放不同的聲音格式。

希望它可以幫助你..