title: QMediaPlayer.play() doesn't work if I call a function with it
body: <p>I'm creating an Audio player with Qt and I'm implementing that when I load a song it start automaticaly, but when I call the function for start the song and calculate the duration, the song doesn't start. I used the debug and when I reach the play function debug stopped with end-stepping-range. I have also tried to emit a signal but nothing to do, the song start only if I press the Play button.</p>
  
  <p>Here there is the code</p>
  
  <pre><code>void AudioPlayer::loadClicked()
  {
      QString filename = QFileDialog::getOpenFileName(this, "Select an audio file", "C:/Users/belli/Music" ,"File Mp3 (*.mp3)");
  
      if(!filename.isEmpty())
      {
          qDebug("%s", filename.toLatin1().constData());
          player.setMedia(QUrl::fromLocalFile(filename));
          this-&gt;volumeSliderMoved();
          QFileInfo fi(filename);
          QString name = fi.fileName();
          ui-&gt;label-&gt;setText(name);
          this-&gt;playClicked();
      }
  }
  
  void AudioPlayer::playClicked()
  {
      player.play();
      songLength = player.duration();
      ui-&gt;horizontalSliderPosition-&gt;setRange(0, songLength);
  }
  
  void AudioPlayer::stopClicked()
  {
      player.stop();
      ui-&gt;horizontalSliderPosition-&gt;setValue(0);
  }
  
  void AudioPlayer::playerPositionChanged(qint64 pos)
  {
     ui-&gt;horizontalSliderPosition-&gt;setValue(pos);
     if(pos == songLength)
         this-&gt;stopClicked();
  }
  
  void AudioPlayer::volumeSliderMoved()
  {
      player.setVolume(ui-&gt;horizontalSliderVolume-&gt;value());
  }
  
  void AudioPlayer::positionSliderMoved()
  {
      player.setPosition((quint64) ui-&gt;horizontalSliderPosition-&gt;value());
  }
  </code></pre>
  
  <p>And the connects</p>
  
  <pre><code>ui(new Ui::AudioPlayer)
  {
      ui-&gt;setupUi(this);
      connect(ui-&gt;pushButtonLoad, SIGNAL(clicked(bool)), SLOT(loadClicked()));
      connect(ui-&gt;pushButtonPlay, SIGNAL(clicked(bool)), SLOT(playClicked()));
      connect(ui-&gt;pushButtonStop, SIGNAL(clicked(bool)), SLOT(stopClicked()));
      connect(ui-&gt;horizontalSliderVolume, SIGNAL(valueChanged(int)), SLOT(volumeSliderMoved()));
      connect(ui-&gt;horizontalSliderPosition, SIGNAL(sliderReleased()), SLOT(positionSliderMoved()));
  
      connect(&amp;player, SIGNAL(positionChanged(qint64)), SLOT(playerPositionChanged(qint64)));
  }
  </code></pre>