2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Using media player for voice / video messages.

Media::Player::Widget displays the current voice / video message
if it is played and the current song otherwise.

It is created when a voice / video message starts and is destroyed
when all the voice / video messages in the playlist are finished.
This commit is contained in:
John Preston
2017-05-21 16:16:39 +03:00
parent 2661fe5cd5
commit 7873cb4373
24 changed files with 325 additions and 192 deletions

View File

@@ -218,18 +218,6 @@ TimeMs FFMpegReaderImplementation::durationMs() const {
return (_fmtContext->streams[_streamId]->duration * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
}
void FFMpegReaderImplementation::pauseAudio() {
if (_audioStreamId >= 0) {
Player::mixer()->pause(_audioMsgId, true);
}
}
void FFMpegReaderImplementation::resumeAudio() {
if (_audioStreamId >= 0) {
Player::mixer()->resume(_audioMsgId, true);
}
}
bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const QSize &size) {
Expects(_frameRead);
_frameRead = false;
@@ -425,7 +413,7 @@ bool FFMpegReaderImplementation::start(Mode mode, TimeMs &positionMs) {
positionMs = countPacketMs(&packet);
}
if (_audioStreamId >= 0) {
if (hasAudio()) {
auto position = (positionMs * soundData->frequency) / 1000LL;
Player::mixer()->play(_audioMsgId, std::move(soundData), position);
}
@@ -480,10 +468,6 @@ QString FFMpegReaderImplementation::logData() const {
}
FFMpegReaderImplementation::~FFMpegReaderImplementation() {
if (_audioStreamId >= 0) {
Player::mixer()->stop(_audioMsgId);
}
clearPacketQueue();
if (_frameRead) {