Qt中声子音频播放器的循环问题
歌曲在 Phonon 音频播放器中设置为静态。该循环使用 aboutToFinish()
进行工作。问题是歌曲结束时有 1 秒的延迟,然后歌曲重复播放。 我们怎样才能避免延误呢?我还存储在临时缓冲区中(使用 QBuffer)来播放它。但它没有给出循环问题的解决方案。
musicpath="sound/sample.mp3";
Phonon::AudioOutput *audioOutput;
Phonon::VolumeSlider *volumeSlider;
Phonon::MediaObject *mediaObject;
mediaObject = new Phonon::MediaObject(this);
mediaObject->setCurrentSource(Phonon::MediaSource( musicpath));
connect(mediaObject, SIGNAL(aboutToFinish()),mediaObject,SLOT(stop()));
connect(mediaObject, SIGNAL(aboutToFinish()),mediaObject,SLOT(play()));
Phonon::createPath(mediaObject, audioOutput);
volumeSlider->setAudioOutput(audioOutput);
mediaObject->play();
A song is set as static in Phonon audio player. The loop works using aboutToFinish()
. The problem is that there is a 1 sec delay at the end of the song, then the song repeats.
How can we avoid the delay? I have also stored in a temporary buffer (using QBuffer
), for playing it. But it is not giving solution for looping issue.
musicpath="sound/sample.mp3";
Phonon::AudioOutput *audioOutput;
Phonon::VolumeSlider *volumeSlider;
Phonon::MediaObject *mediaObject;
mediaObject = new Phonon::MediaObject(this);
mediaObject->setCurrentSource(Phonon::MediaSource( musicpath));
connect(mediaObject, SIGNAL(aboutToFinish()),mediaObject,SLOT(stop()));
connect(mediaObject, SIGNAL(aboutToFinish()),mediaObject,SLOT(play()));
Phonon::createPath(mediaObject, audioOutput);
volumeSlider->setAudioOutput(audioOutput);
mediaObject->play();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最好的选择是检查视频状态是使用 1 毫秒的计时器并在结束时播放
I think best choice is checking for state of video is by using timer with 1 ms and play it if end