×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    28

    Phonon VolumeSlider current volume position not working

    I have created a volumeSlider, which works:

    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    mediaObject = new Phonon::MediaObject(this);
    Phonon::createPath(mediaObject, audioOutput);
    volumeSlider = new Phonon::VolumeSlider(ui->volumeSlider);
    volumeSlider->setFixedWidth(200);
    volumeSlider->setAudioOutput(audioOutput);
    volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    However, when the volumeSlider is shown it always is set to the maximum position, even when I set the volume using:

    audioOutput->setVolume(50);
    volumeSlider->setAudioOutput(audioOutput);

    Any ideas as to what I'm doing wrong?

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: Phonon VolumeSlider current volume position not working

    I am not sure but I think setVolume takes percentage as input. can you try setting 0.5 in setVolume and see what happens ?
    http://kunalmaemo.blogspot.com/

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    28

    Re: Phonon VolumeSlider current volume position not working

    thanks. works now

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    28

    Re: Phonon VolumeSlider current volume position not working

    This works when I play a file. I can pause it and on resume the volume is as per the slider.

    If I press stop on my player and play the file again, the volume resets and the slider value is ignored.

    Here's the code:

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    mediaObject = new Phonon::MediaObject(this);
    Phonon::createPath(mediaObject,audioOutput);
    audioOutput->setVolume(0.75);

    volumeSlider = new Phonon::VolumeSlider(this);
    volumeSlider->setAudioOutput(audioOutput);
    volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
    volumeSlider->setFixedWidth(200);

    ui->setupUi(this);
    ui->volumeLayout->addWidget(volumeSlider);

    connect(this->ui->playButton, SIGNAL(clicked()), this, SLOT(playMyAudio()));
    connect(this->ui->pauseButton, SIGNAL(clicked()), this, SLOT(pauseMyAudio()));
    connect(this->ui->stopButton, SIGNAL(clicked()), this, SLOT(stopMyAudio()));
    }

    void MainWindow:layMyAudio()
    {
    QString privatePathQt(QDir::homePath());
    QString privatePathSymbian(privatePathQt.replace("/","\\"));
    mediaObject->setCurrentSource(Phonon::MediaSource(privatePathSymbian + "\\pPlayer\\audio1.wma"));
    mediaObject->play();
    }

  5. #5
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: Phonon VolumeSlider current volume position not working

    can you also paste code for stopMyAudio function ?

    Thanks
    http://kunalmaemo.blogspot.com/

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    28

    Re: Phonon VolumeSlider current volume position not working

    <code>
    void MainWindow::stopMyAudio()
    {
    if (mediaObject->state() == Phonon::PlayingState)
    {
    this->ui->label->setText("Stop");
    mediaObject->stop();
    }
    }

    void MainWindow::CheckstateChanged()
    {
    if (mediaObject->state() == Phonon::LoadingState)
    {
    this->ui->label->setText("Load");
    }
    if (mediaObject->state() == Phonon::StoppedState)
    {
    this->ui->label->setText("Stop");
    }
    if (mediaObject->state() == Phonon::PlayingState)
    {
    this->ui->label->setText("Play");
    }
    if (mediaObject->state() == Phonon::PausedState)
    {
    this->ui->label->setText("Pause");
    }
    if (mediaObject->state() == Phonon::ErrorState)
    {
    this->ui->label->setText("Error");
    this->ui->label3->setText(mediaObject->errorString());
    }
    }

    </code>

    The problem also happens when an audio track finishes playing and I try play it again.
    Last edited by abashir; 2010-12-23 at 13:26. Reason: reformatted

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: Phonon VolumeSlider current volume position not working

    code looks fine to me, not sure why this could happen. you can try creating path again just to see if it works ?
    http://kunalmaemo.blogspot.com/

  8. #8
    Registered User
    Join Date
    Mar 2009
    Posts
    28

    Re: Phonon VolumeSlider current volume position not working

    Quote Originally Posted by kunal_the_one View Post
    code looks fine to me, not sure why this could happen. you can try creating path again just to see if it works ?
    I have amended the playAudio code as follows:

    Code:
            QString audiofile = audioPath + QString::number(pagecount) + ".wma";
            mediaObject->setCurrentSource(Phonon::MediaSource(audiofile));
            Phonon::createPath(mediaObject, audioOutput);
            mediaObject->play();
    I am setting the volume to 90% in the main flow

    audioOutput->setVolume(0.9);


    1. The volume is not v loud, but when I move the volumeslider it increases.

    2. When I play the file again, the audio volume is reduced again

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    166

    Re: Phonon VolumeSlider current volume position not working

    it seems that using native device api is the way to handle volume in symbian,

    #ifdef Q_OS_SYMBIAN
    // include Symbian sound device
    #include <SoundDevice.h>
    #endif

    #ifdef Q_OS_SYMBIAN
    unsigned int *pointer_to_abstract_audio = (unsigned int*)( (unsigned char*)m_audioOutput + 8
    );
    unsigned int *dev_sound_wrapper = (unsigned int*)(*pointer_to_abstract_audio) + 13;
    unsigned int *temp = ((unsigned int*)(*dev_sound_wrapper) + 6);
    CMMFDevSound *dev_sound = (CMMFDevSound*)(*temp);
    dev_sound->SetVolume(dev_sound->MaxVolume());
    #endif

    Code is from following pdf document,section 7.10

    http://www.developer.nokia.com/info/...evelopers.html
    http://kunalmaemo.blogspot.com/

Similar Threads

  1. Navipane Volume indicator position problem
    By manjusg in forum Symbian C++
    Replies: 7
    Last Post: 2010-10-26, 08:24
  2. Showing the current position using the Google Maps API
    By chandran.biju007 in forum Symbian C++
    Replies: 0
    Last Post: 2010-04-29, 07:47
  3. How to get the current LoudSpeaker Volume 3rdSDK
    By pistha in forum Symbian C++
    Replies: 2
    Last Post: 2007-08-29, 12:22
  4. How to get system current volume in S60 3rd?
    By Kiss_Fish in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-05-11, 10:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •