qmediaplayer获取流类型_QMediaplayer流从自定义QIODevice在Mac OS(10.9)加密

i'm currently porting an application from Qt4(.8.4) to Qt5(.2.0).

I'm nearly done with all the known changes like deprecated toAscii()-function, missing QtGui and so on. Now we had a music player using the phonon framework which is not supported any more and got replaced by the QtMultimedia module including the QMediaPlayer and a bunch of Audio-Handling classes.

Our implementation of the player takes a custom QIODevice. This device provides an interface to encrypted audiofiles on the disk. Now the player asks the device for x bytes, the device reads from the encrypted file, decrypts the bytes the player asked for and returns them.

Now I searched for a function in the multimedia-module to reuse my IODevice and found the following function:

void setMedia(const QMediaContent & media, QIODevice * stream = 0)

and used it as follows:

m_pDecryptingMediaDevice = new BYIODevice(filename);

m_pDecryptingMediaDevice->open(QIODevice::ReadOnly);

m_pPlayer->setMedia(0, m_pDecryptingMediaDevice);

where m_pDecryptingMediaDevice is the QIODevice-subclass and m_pPlayer the QMediaPlayer.

Now on Windows everything works as expected. The QMediaplayer changes its MediaStatus to QMediaPlayer::LoadingMedia and asks my device for bytes. Then changes to the QMediaPlayer::State PlayingState and the status is set to BufferedMedia.

Everythings fine.

Unfortunalety on Mac OS (10.9.1) I only get QMediaPlayer::PlayingState and nothing more. The player/audiobackend never asks my device for bytes and doesn't call any other function.

I don't think that the mistake is concerned to the custom QIODevice but in the way it is given to the QMediaPlayer because the player doesn't even ask for any bytes or calls any function on the device.

I just tried to break it down to a little testproject:

QMediaPlayer *player = new QMediaPlayer(this);

QFile *music = new QFile("C:/Users/.../Music/Test.mp3");

music->open(QIODevice::ReadOnly);

player->setMedia(0, music);

connect(ui->pushButton, SIGNAL(clicked()), player, SLOT(play()));

connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stateChanged(QMediaPlayer::State)));

Curiously this does not play at all - not on windows, not on Mac OS.

What always works is giving an URL to the player like

Has someone any experience in a similar case according to streaming out of an QIODevice to QMediaPlayer using the function setMedia(const QMediaContent & media, QIODevice * stream = 0)? I am stuck with this.

Best regards and many thanks in advance.

Jan

解决方案

Just came to this page. There the available/chosen audio-backends for each platform are listed:

As you can see the DirectShow-Plugin (Windows) does support stream sources whereas AVM Foundation/Quicktime 7 (OSX) don't have streaming support. So I guess the only solution seems to ship a custom backend with the application (gstreamer, vlc).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值