【问题标题】:Unable to play 3gp file in iOS无法在 iOS 中播放 3gp 文件
【发布时间】:2014-09-01 06:42:37
【问题描述】:

有人可以帮我解决这个问题吗?

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

【问题讨论】:

  • 您在哪个文档中看到了 3gp ?
  • 支持 3gp,但请确保您的 3gp 符合苹果标准。 (分辨率和fps等)

标签: ios avplayer mpmovieplayer


【解决方案1】:

我正在使用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 文件。

这个音频工具箱也可以播放不同的声音格式。

希望对你有帮助..

【讨论】:

    猜你喜欢
    • 2011-09-21
    • 2014-11-02
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多