⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

How to change audio output device in qmediaplayer

  • Hi,

    is there an easy way to set the audio output device when I use the QMediaPlayer class in QtMultimediaKit?
    I mean something comparable to the handling of input devices in QMediaRecorder like this:
    audiosource = new QAudioCaptureSource;
    capture = new QMediaRecorder(audiosource);
    where "my_soundcard" is the name of the device I wish to use.

    I need this for cross platform desktop applications on machines with more than one sound card.
    Till now I used phonon and know the way to do this. But to switch to QtMultimediaKit there should be a similar easy way.

    BTW the QtMultimediaKit module looks very promising for me. Thanks so far!

  • Short answer: seems that it is no simple way to do this.

    Long answer: QMediaPlayer::play() calls QMediaPlayerControl::play().

    QMediaPlayerControl object is created in QMediaPlayer constructor
    (changed for better reading):

    @QMediaServiceProvider provider;
    QMediaService * service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER);
    control = qobject_cast<QMediaPlayerControl*>

    No other assignments to the "control" variable in the QMediaPlayer code, so, control binds to the output on initialization.

    It is result of brief searching the code, maybe I am missed something.

  • Ok,

    as far as I can see, the QAudioEndpointSelector class is used for this and the plugins (directshow, gstreamer, symbian) have to inherit this class and implement the features for the underlying audio system. But unfortunately only in symbian and directshow (see ../qt-mobility-opensource-src-1.1.0/plugins/multimedia/...) exists the classes S60MediaPlayerAudioEndpointSelector and respectively DirectShowAudioEndpointControl but not for gstreamer. So the question is now (are there the some of the writers here?): will it be implemented for gstreamer so I can use this under linux and when?

    kind regards!

Log in to reply