November 21, 2010

smue_mi smue_mi
Lab Rat
1 posts

How to change audio output device in qmediaplayer



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:

  1. audiosource = new QAudioCaptureSource;
  2. capture = new QMediaRecorder(audiosource);
  3. audiosource->setAudioInput("my_soundcard");

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!

2 replies

November 21, 2010

blex blex
Lab Rat
171 posts

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):

  1. QMediaServiceProvider *provider;
  2. QMediaService * service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER);
  3. QMediaPlayerControl* control = qobject_cast<QMediaPlayerControl*>
  4.     (service->requestControl(QMediaPlayerControl_iid));

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.



Oleksiy Balabay

November 22, 2010

smue_mi smue_mi
Lab Rat
1 posts


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!

  ‹‹ [Qt Message] exception on 3 [will close the socket handle - hack]      Development for Symbian^3 on Linux ››

You must log in to post a reply. Not a member yet? Register here!