K
K
KobraMiner2018-08-20 23:18:55
Qt
KobraMiner, 2018-08-20 23:18:55

How to set input for QMediaPlayer?

In general, there is a player, and there is a combobox with available devices. And it is necessary that when choosing a device, the player sounds in a different output, try this:

QMediaService *svc = player->service(); 
if (svc != nullptr) 
{ 
    QAudioOutputSelectorControl *out = qobject_cast<QAudioOutputSelectorControl *> 
             (svc->requestControl(QAudioOutputSelectorControl_iid)); 
    if (out != nullptr) 
    { 
     out->setActiveOutput(this->ui->comboBox->currentText()); 
     svc->releaseControl(out); 
    } 
}

But it doesn't work: there are no errors, but it just doesn't want to get out. How to fix?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question