QPlayer class

Sends media commands to mm-player and emits signals for media state changes.


#include <qplayer/qplayer.h>

namespace QPlayer {

    static const QString ROOT_MEDIA_NODE_ID = 
    class QPLAYER_EXPORT QPlayer : public QObject
        explicit QPlayer( const QString playerName, 
                          QObject *parent = 0 );
        void getMediaSources( MediaSourcesCommand *command );
        void getPlayerState( PlayerStateCommand *command );
        void getCurrentTrack( CurrentTrackCommand *command );
        void getCurrentTrackPosition( 
                      CurrentTrackPositionCommand *command );
        void browse( BrowseCommand *command );
        void search( SearchCommand *command );
        void getMetadata( MetadataCommand *command );
        void getExtendedMetadata( 
                        ExtendedMetadataCommand *command );
        void createTrackSession( 
                        CreateTrackSessionCommand *command );
        int destroyTrackSession( uint64_t tsid );
        void getTrackSessionItems(
                        TrackSessionItemsCommand *command );
        void getCurrentTrackSessionInfo( 
                            TrackSession *trackSession );
    public Q_SLOTS:
        void play();
        void pause();
        void stop();
        void next();
        void previous();
        void seek( const int position );
        void jump( const int index );

        void setPlaybackRate( const float rate );
        void setShuffleMode( const PlayerState::ShuffleMode mode );
        void setRepeatMode( const PlayerState::RepeatMode mode );

        void playerReady();

        void mediaSourceChanged( 
                            const MediaSourceEventType type,
                            const MediaSource &mediaSource );
        void trackChanged( Track track );
        void trackPositionChanged( int trackPosition );
        void trackSessionChanged( TrackSessionEventType type, 
                                  TrackSession trackSession );
        void playerStateChanged( PlayerState playerState );





Sends media commands to mm-player and emits signals for media state changes. The QPlayer class is the main class that your apps use to interact with the QPlayer library.

When creating QPlayer objects, you must name the player you want to connect with. The reference HMI uses the same player in the Media Player app (which provides visual media controls) and the ASR subsystem (which supports voice commands related to media). For more information about players, see the mm_player_open() function in the Multimedia Player Developer's Guide.

The new QPlayer object waits (if necessary) until mm-player is ready before trying to open the specified player. If successful, it emits the playerReady signal. You can then use the object to browse media sources, retrieve metadata, create tracksessions, and manage playback. The object will emit signals when the player's state changes. If it can't open the player, the QPlayer library logs an error.

Results-based media commands, such as media node searches or metadata retrieval requests, use command classes. This means you must specify operation details (e.g., which folder to search) in a command object, which the library also uses to return the results. For commands that retrieve state information (e.g., player status or information on the current track), the command object is used only for returning results. Note that you must wait for any command object to emit a complete signal before retrieving the operation results; otherwise, the results will be empty.

Playback functions don't require command objects because they carry out relatively basic actions, such as starting and stopping playback or changing tracks. All playback functions are implemented as Qt slots, so you can connect them to signals so that they run in response to user actions. For example, you can connect playback functions to signals emitted by a GUI after the user taps an HMI button.

This class also defines signals that, when emitted, indicate changes to: