首先 强烈建议, IOS和安卓支持wav播放,这样的话,PC不需要修改
可以百度下 iOS4.3之后就不支持AMR了, 所以建议IOS,安卓 优先支持WAV 【系统本身是支持的】
如果IOS和安卓不支持WAV怎么办呢
我目前通过ffmpeg 曲线救国 解决了
参考帖 https://www.cnblogs.com/xiaofengfeng/p/3573025.html
具体方式 下载ffmpeg 编译成ffmpeg .exe
// amr转wav ./ffmpeg -i 1.amr 1.wav
bool convertAMR2WAV(QString srcPath, QString destPath)
{
QString errMsg ="convertAMR2WAV Result is : srcFile:";
errMsg.append(srcPath).append(" ; destFile:").append(destPath);
QProcess * po = new QProcess(nullptr);
AppConfig config =ConfigManager::getInstance()->m_AppConfig;
QString program = config.FFMPEGDIR;
QStringList argu;
argu.append("-i");
argu.append(srcPath);
argu.append(destPath);
argu.append("-y"); //强制替换
int result =po->execute(program,argu);
if(result ==0)
{
qDebug()<<errMsg<<" done!";
return true;
}
qDebug()<<errMsg<<" error!!";
return false;
}
bool convertWAV2AMR(QString srcPath, QString destPath)
{
removeExistFile(destPath);
QProcess * po = new QProcess(nullptr);
AppConfig config =ConfigManager::getInstance()->m_AppConfig;
QString program = config.FFMPEGDIR;
QStringList argu;
argu.append("-i");
argu.append(srcPath);
argu.append("-ar");
argu.append("8000");
argu.append("-ab");
argu.append("12.2k");
argu.append("-ac");
argu.append("1");
argu.append(destPath);
int result =po->execute(program,argu);
QString errMsg ="convertWAV2AMR Result is : srcFile:";
errMsg.append(srcPath).append(" ; destFile:").append(destPath);
if(result==0)
{
qDebug()<<errMsg<<" done!";
return true;
}
qDebug()<<errMsg<<" error!";
return false;
}