找回密码
 立即注册
收起左侧

QMediaPlaylist播放每个项目间默认停顿时间比较长怎么解决

0
回复
4006
查看
[复制链接]

尚未签到

来源: 2020-11-16 12:09:42 显示全部楼层 |阅读模式
1Qter豆
            利用QMediaPlayer播放本地录音文件,因为是片段的,利用QMediaPlaylist拼接音频,播放后QMediaPlaylist两个媒体文件间默认停顿时间比较慢,听上去比较别扭,setPlaybackRate只能控制播放速度,对两个录音文件间的间隔还是怎么优化或者控制两个媒体文件间这个停顿时间?

QMediaPlaylist *playList = new QMediaPlaylist;
if (payWay == QString("微信"))
{
playList->addMedia(QUrl::fromLocalFile(soundPath+"wx.wav"));
}
if (payWay == QString("支付宝"))
{
playList->addMedia(QUrl::fromLocalFile(soundPath+"zfb.wav"));
}
if (payWay == QString("银联"))
{
playList->addMedia(QUrl::fromLocalFile(soundPath+"yl.wav"));
}
// 根据金额拼接语音
QStringList listStr = money.split(".");
QString intStr = listStr.at(0);         // 整数部分
QString dotStr = listStr.at(1);         // 小数部分
qDebug()<<"intStr:"<<intStr<<"dotStr:"<<dotStr;
// 整数部分
if (intStr.length() == 1)
{
soundUnitTurn(intStr, playList);
}
if (intStr.length() == 2)
{
soundUnitTurn(intStr.left(1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"shi.wav"));
if ("0" != intStr.right(1))
{
soundUnitTurn(intStr.right(1), playList);
}
}
if (intStr.length() == 3)
{
soundUnitTurn(intStr.left(1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"bai.wav"));
if ("00" != intStr.right(2))
{
soundUnitTurn(intStr.mid(1,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"shi.wav"));
if ("0" != intStr.right(1))
{
soundUnitTurn(intStr.mid(2), playList);
}
}
}
if (intStr.length() == 4)
{
soundUnitTurn(intStr.left(1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"qian.wav"));
if ("000" != intStr.mid(1))
{
soundUnitTurn(intStr.mid(1,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"bai.wav"));
if ("00" != intStr.right(2))
{
soundUnitTurn(intStr.mid(2,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"shi.wav"));
if ("0" != intStr.right(1))
{
soundUnitTurn(intStr.mid(3), playList);
}
}
}
}
if (intStr.length() == 5)
{
soundUnitTurn(intStr.left(1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"wan.wav"));
if ("0000" != intStr.mid(1))
{
soundUnitTurn(intStr.mid(1,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"qian.wav"));
if ("000" != intStr.right(3))
{
soundUnitTurn(intStr.mid(2,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"bai.wav"));
if ("00" != intStr.right(2))
{
soundUnitTurn(intStr.mid(3,1), playList);
playList->addMedia(QUrl::fromLocalFile(soundPath+"shi.wav"));
if ("0" != intStr.right(1))
{
soundUnitTurn(intStr.mid(4), playList);
}
}
}
}
}
if ("00" != dotStr)
{
playList->addMedia(QUrl::fromLocalFile(soundPath+"dian.wav"));
soundUnitTurn(dotStr.left(1), playList);
if ("0" != dotStr.right(1))
{
soundUnitTurn(dotStr.right(1), playList);
}
playList->addMedia(QUrl::fromLocalFile(soundPath+"yuan.wav"));
}
if ("00" == dotStr)
{
playList->addMedia(QUrl::fromLocalFile(soundPath+"yuan.wav"));
}
playList->setCurrentIndex(0);
player->setPlaylist(playList);
player->setPlaybackRate(1.1);
player->play();

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了