CCIMXDesktop
 
Loading...
Searching...
No Matches
MediaPlayer Class Reference

MediaPlayer is the wrapper of VideoPlayer and AudioPlayer, with the sync of video and audio basically. More...

#include <MediaPlayer.h>

Inheritance diagram for MediaPlayer:

Classes

struct  MediaPlayerStatus
 The MediaPlayerStatus class measures the status of the media player. More...
 

Signals

void display_frame (QImage image)
 display_frame display the frame by hooking this signals
 
void volumeChanged (float percentage)
 volumeChanged the signal indicating the volume changed
 
void sourceOpened (const QString source, MediaPlayer::MediaPlayerStatus status)
 sourceOpened the signal indicating the source opened
 
void videoAvailable (bool sourceAvailable, const QImage firstPage)
 videoAvailable for mp4 like video, this means we can display the medias
 
void mediaEnd ()
 mediaEnd the signal indicating the media end
 
void durationChanged (qint64 new_durantion)
 durationChanged the signal indicating the duration changed
 
void positionChanged (qint64 position)
 positionChanged the signal indicating the position changed
 
void metaDataAvailable (const MediaInfo info)
 metaDataAvailable the signal indicating the meta data available
 

Public Member Functions

 MediaPlayer (QObject *parent=nullptr)
 Construct a new Media Player object.
 
 Q_DISABLE_COPY (MediaPlayer)
 disable copy
 
void setSource (const char *local_file)
 setSource set the source of the media
 
QString source () const
 source get the source of the media
 
void setVolume (const float percentage)
 setVolume set the volume of the media
 
float volume () const
 volume get the volume of the media
 
qint64 get_durations () const
 get_durations get the durations of the media
 
qint64 get_position () const
 get_position get the position of the media
 
bool resume ()
 resume start the media player
 
bool pause ()
 pause pause the media player
 
bool close ()
 close close the media player
 
bool isPlaying () const
 isPlaying check if the media is playing
 
void set_accept_missync_msecond (const unsigned int msec=MediaPlayerPublicSettings::DEF_ACCPET_DELAY)
 set_accept_missync_msecond set the default mis sync tolerance
 
void set_position (const qint64 position)
 set_position moves to the target positions of the media
 

Detailed Description

MediaPlayer is the wrapper of VideoPlayer and AudioPlayer, with the sync of video and audio basically.

Note
Author here in 2025.5.10 In Current Version, Only OpenCV is supported for the video play and the audio is only supported by QMediaPlayer, with current ALSA is used for the audio play in IMX6ULL, so for cross compilers you must cross compile with ALSA support

Constructor & Destructor Documentation

◆ MediaPlayer()

MediaPlayer::MediaPlayer ( QObject *  parent = nullptr)
explicit

Construct a new Media Player object.

Parameters
parent

Member Function Documentation

◆ close()

bool MediaPlayer::close ( )

close close the media player

Returns
true if the media close OK
Note
close will release the media sources will pause don't, whom, just simply hang the media

◆ display_frame

void MediaPlayer::display_frame ( QImage  image)
signal

display_frame display the frame by hooking this signals

Parameters
imagethe image to display
Note
for those who expect to use callback shell get the image, this image is the image you should display query from media underlevel

◆ durationChanged

void MediaPlayer::durationChanged ( qint64  new_durantion)
signal

durationChanged the signal indicating the duration changed

Parameters
new_durantionthe new duration of the media

◆ get_durations()

qint64 MediaPlayer::get_durations ( ) const
inline

get_durations get the durations of the media

Returns
the durations of the media

◆ get_position()

qint64 MediaPlayer::get_position ( ) const
inline

get_position get the position of the media

Returns
the position of the media

◆ isPlaying()

bool MediaPlayer::isPlaying ( ) const

isPlaying check if the media is playing

Returns
true if the media is playing
Note
see if the audio is playing thus for default, if one is playing, the mediaplayer is playing :)

◆ metaDataAvailable

void MediaPlayer::metaDataAvailable ( const MediaInfo  info)
signal

metaDataAvailable the signal indicating the meta data available

Parameters
infothe meta data of the media

◆ pause()

bool MediaPlayer::pause ( )

pause pause the media player

Returns
true if the media pause OK

◆ positionChanged

void MediaPlayer::positionChanged ( qint64  position)
signal

positionChanged the signal indicating the position changed

Parameters
positionthe new position of the media

◆ resume()

bool MediaPlayer::resume ( )

resume start the media player

Returns
true if the media resume OK
Note
start the display if, the source is displayable and source is ready

◆ set_accept_missync_msecond()

void MediaPlayer::set_accept_missync_msecond ( const unsigned int  msec = MediaPlayerPublicSettings::DEF_ACCPET_DELAY)
inline

set_accept_missync_msecond set the default mis sync tolerance

Parameters
msecthe msecond to accept

◆ set_position()

void MediaPlayer::set_position ( const qint64  position)

set_position moves to the target positions of the media

Parameters
positionthe position to set

◆ setSource()

void MediaPlayer::setSource ( const char *  local_file)

setSource set the source of the media

Parameters
local_filethe local file to open
Note
this actually bind the media we operate

◆ setVolume()

void MediaPlayer::setVolume ( const float  percentage)

setVolume set the volume of the media

Parameters
percentagethe percentage of the volume
Note
this is the percentage of the volume, not the value that without %, that is, the value should be between 0 and 1, not 0 and 100!

◆ source()

QString MediaPlayer::source ( ) const

source get the source of the media

Returns
the source of the media

◆ sourceOpened

void MediaPlayer::sourceOpened ( const QString  source,
MediaPlayer::MediaPlayerStatus  status 
)
signal

sourceOpened the signal indicating the source opened

Parameters
sourcethe source of the media
statusthe status of the media for what errors
Parameters
sourceAt which sources

◆ videoAvailable

void MediaPlayer::videoAvailable ( bool  sourceAvailable,
const QImage  firstPage 
)
signal

videoAvailable for mp4 like video, this means we can display the medias

Parameters
sourceAvailablethe source is available
firstPagethe first page of the media for display

◆ volume()

float MediaPlayer::volume ( ) const

volume get the volume of the media

Returns
the volume of the media
Note
this is the percentage of the volume, not the value that without %, that is, the value should be between 0 and 1, not 0 and 100!

◆ volumeChanged

void MediaPlayer::volumeChanged ( float  percentage)
signal

volumeChanged the signal indicating the volume changed

Parameters
percentagethe percentage of the volume
Note
this is the percentage of the volume, not the value that without %, that is, the value should be between 0 and 1, not 0 and 100!

The documentation for this class was generated from the following files: