×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Aug 2003
    Posts
    128

    Unhappy music cannot loop for Phonon media object

    Hi,

    I have a piece of music which i want to play it continuously. I used the following codes, it can play but the music doesn't loop.

    music = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(":/music/sound/AfternoonStreets.wav"));
    connect(music, SIGNAL(finished()), SLOT(musicFinished()));

    void MainWindow::musicFinished(){
    music->play();
    }

    any idea why? what am i doing wrong?

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: music cannot loop for Phonon media object

    This is from documentation http://doc.qt.nokia.com/4.6/phonon-m....html#finished
    Warning: This signal is not emitted when the current source has finished and there's another source in the queue. It is only emitted when the queue is empty.

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: music cannot loop for Phonon media object

    This application work for me
    Code:
    #ifndef MAIN_H
    #define MAIN_H
    
    #include <QMainWindow>
    #include <phonon/MediaObject>
    #include <phonon/VideoWidget>
    #include <phonon/AudioOutput>
    
    class Player : public QMainWindow
    {
        Q_OBJECT
    
    public:
        Player(QWidget *parent = 0);
    
    public slots:
        void play();
    
    private slots:
        void finished();
    
    private:
        Phonon::MediaObject *mediaObject;
    };
    
    #endif // MAIN_H
    Code:
    #include <QApplication>
    
    #include "main.h"
    
    Player::Player(QWidget *parent) : QMainWindow(parent)
    {
        mediaObject = new Phonon::MediaObject(parent);
        Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, parent);
        Phonon::createPath(mediaObject, audioOutput);
    
        connect(mediaObject, SIGNAL(finished()), SLOT(finished()));
    }
    
    void Player::play()
    {
        mediaObject->setCurrentSource(Phonon::MediaSource("file:///home/user/MyDocs/.sounds/Total Fantasy.mp3"));
        mediaObject->play();
    }
    
    void Player::finished()
    {
        play();
    }
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        a.setApplicationName("Minimalistic Media Player");
        a.setOrganizationName("Maemo");
    
        Player player;
        player.show();
        player.play();
    
        return a.exec();
    }

  4. #4
    Regular Contributor
    Join Date
    Aug 2003
    Posts
    128

    Re: music cannot loop for Phonon media object

    Quote Originally Posted by divanov View Post
    This application work for me
    Code:
    #ifndef MAIN_H
    #define MAIN_H
    
    #include <QMainWindow>
    #include <phonon/MediaObject>
    #include <phonon/VideoWidget>
    #include <phonon/AudioOutput>
    
    class Player : public QMainWindow
    {
        Q_OBJECT
    
    public:
        Player(QWidget *parent = 0);
    
    public slots:
        void play();
    
    private slots:
        void finished();
    
    private:
        Phonon::MediaObject *mediaObject;
    };
    
    #endif // MAIN_H
    Code:
    #include <QApplication>
    
    #include "main.h"
    
    Player::Player(QWidget *parent) : QMainWindow(parent)
    {
        mediaObject = new Phonon::MediaObject(parent);
        Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, parent);
        Phonon::createPath(mediaObject, audioOutput);
    
        connect(mediaObject, SIGNAL(finished()), SLOT(finished()));
    }
    
    void Player::play()
    {
        mediaObject->setCurrentSource(Phonon::MediaSource("file:///home/user/MyDocs/.sounds/Total Fantasy.mp3"));
        mediaObject->play();
    }
    
    void Player::finished()
    {
        play();
    }
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        a.setApplicationName("Minimalistic Media Player");
        a.setOrganizationName("Maemo");
    
        Player player;
        player.show();
        player.play();
    
        return a.exec();
    }

    Hi divanov ,

    you tested in maemo?

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: music cannot loop for Phonon media object

    Quote Originally Posted by zhenLeow View Post
    Hi divanov ,

    you tested in maemo?
    Yes, I've tried the code on Maemo 5.

Similar Threads

  1. Replies: 2
    Last Post: 2007-10-05, 20:40
  2. RunL() method is not being called
    By dotcdotc in forum Symbian
    Replies: 9
    Last Post: 2004-12-13, 11:25
  3. Replies: 1
    Last Post: 2003-11-28, 10:23
  4. structure of media object (MMS body)?????
    By alinesimon in forum General Messaging
    Replies: 1
    Last Post: 2002-07-26, 04:55
  5. Nokia 22- Loop current Reversal
    By Nokia_Archived in forum Nokia M2M
    Replies: 1
    Last Post: 2002-05-20, 14:39

Posting Permissions

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