Miam-Player  0.8.0
A nice music player
QtAV::AVPlayer Class Reference

The AVPlayer class Preload: More...

#include <AVPlayer.h>

Inheritance diagram for QtAV::AVPlayer:

Public Types

enum  State { StoppedState, PlayingState, PausedState }
 The State enum The playback state. More...
 

Public Slots

bool load ()
 load Load the current media set by setFile(); Can be used to reload a media and call play() later. More...
 
void togglePause ()
 
void pause (bool p=true)
 
void play ()
 play Load media and start playback. More...
 
void stop ()
 stop Stop playback. More...
 
void stepForward ()
 stepForward Play the next frame and pause More...
 
void stepBackward ()
 stepBackward Play the previous frame and pause. More...
 
void setRelativeTimeMode (bool value)
 
void setRepeat (int max)
 setRepeat Repeat max times between startPosition() and endPosition(). More...
 
void setStartPosition (qint64 pos)
 startPosition Used to repeat from startPosition() to endPosition(). More...
 
void setStopPosition (qint64 pos=std::numeric_limits< qint64 >::max())
 stopPosition pos > mediaStopPosition(): mediaStopPosition() pos < 0: duration() + pos With the default value, the playback will not stop until the end of media (including dynamically changed media duration, e.g. More...
 
void setTimeRange (qint64 start, qint64 stop=std::numeric_limits< qint64 >::max())
 setTimeRange Set startPosition and stopPosition. More...
 
bool isSeekable () const
 
void setPosition (qint64 position)
 setPosition equals to seek(qreal) position < 0: 0 More...
 
void seek (qreal r)
 
void seek (qint64 pos)
 
void seekForward ()
 
void seekBackward ()
 
void setSeekType (SeekType type)
 
SeekType seekType () const
 
qreal bufferProgress () const
 bufferProgress How much the data buffer is currently filled. More...
 
qreal bufferSpeed () const
 bufferSpeed Bytes/s More...
 
qint64 buffered () const
 buffered Current buffered value in msecs, bytes or packet count depending on bufferMode() More...
 
void setBufferMode (BufferMode mode)
 
BufferMode bufferMode () const
 
void setBufferValue (qint64 value)
 setBufferValue Ensure the buffered msecs/bytes/packets in queue is at least the given value before playback starts. More...
 
int bufferValue () const
 
void setNotifyInterval (int msec)
 setNotifyInterval The interval at which progress will update More...
 
int notifyInterval () const
 The real notify interval. Always > 0. More...
 
void updateClock (qint64 msecs)
 
void setBrightness (int val)
 
void setContrast (int val)
 
void setHue (int val)
 
void setSaturation (int val)
 

Signals

void bufferProgressChanged (qreal)
 
void relativeTimeModeChanged ()
 
void autoLoadChanged ()
 
void asyncLoadChanged ()
 
void muteChanged ()
 
void sourceChanged ()
 
void loaded ()
 
void mediaStatusChanged (QtAV::MediaStatus status)
 
void mediaEndActionChanged (QtAV::MediaEndAction action)
 
void durationChanged (qint64)
 durationChanged emit when media is loaded/unloaded More...
 
void error (const QtAV::AVError &e)
 
void paused (bool p)
 
void started ()
 started Emitted when playback is started. More...
 
void stopped ()
 
void stoppedAt (qint64 position)
 
void stateChanged (QtAV::AVPlayer::State state)
 
void speedChanged (qreal speed)
 
void repeatChanged (int r)
 
void currentRepeatChanged (int r)
 
void startPositionChanged (qint64 position)
 
void stopPositionChanged (qint64 position)
 
void seekableChanged ()
 
void seekFinished (qint64 position)
 seekFinished If there is a video stream currently playing, emitted when video seek is finished. More...
 
void positionChanged (qint64 position)
 
void interruptTimeoutChanged ()
 
void interruptOnTimeoutChanged ()
 
void notifyIntervalChanged ()
 
void brightnessChanged (int val)
 
void contrastChanged (int val)
 
void hueChanged (int val)
 
void saturationChanged (int val)
 
void subtitleStreamChanged (int value)
 
void internalAudioTracksChanged (const QVariantList &tracks)
 internalAudioTracksChanged Emitted when media is loaded. More...
 
void externalAudioTracksChanged (const QVariantList &tracks)
 
void internalSubtitleTracksChanged (const QVariantList &tracks)
 
void internalSubtitleHeaderRead (const QByteArray &codec, const QByteArray &data)
 internalSubtitleHeaderRead Emitted when internal subtitle is loaded. More...
 
void internalSubtitlePacketRead (int track, const QtAV::Packet &packet)
 

Public Member Functions

 AVPlayer (QObject *parent=0)
 
 ~AVPlayer ()
 
AVClockmasterClock ()
 masterClock setClockType() should call when playback started. More...
 
void setFile (const QString &path)
 setFile TODO: Set current media source if current media is invalid or auto load is enabled. More...
 
QString file () const
 
void setIODevice (QIODevice *device)
 setIODevice Play media stream from QIODevice. More...
 
void setInput (MediaIO *in)
 setInput Play media stream from custom MediaIO. More...
 
MediaIOinput () const
 
bool isLoaded () const
 
void setAsyncLoad (bool value=true)
 setAsyncLoad async load is enabled by default More...
 
bool isAsyncLoad () const
 
void setAutoLoad (bool value=true)
 setAutoLoad true: current media source changed immediatly and stop current playback if new media source is set. More...
 
bool isAutoLoad () const
 
MediaStatus mediaStatus () const
 
bool relativeTimeMode () const
 relativeTimeMode true (default): mediaStartPosition() is always 0. More...
 
qint64 absoluteMediaStartPosition () const
 Media stream property. The first timestamp in the media. More...
 
qreal durationF () const
 
qint64 duration () const
 
qint64 mediaStartPosition () const
 mediaStartPosition If relativeTimeMode() is true (default), it's 0. More...
 
qint64 mediaStopPosition () const
 mediaStartPosition() + duration(). More...
 
qreal mediaStartPositionF () const
 
qreal mediaStopPositionF () const
 
qint64 startPosition () const
 
qint64 stopPosition () const
 stopPosition: the position at which player should stop playing More...
 
qint64 position () const
 
int repeat () const
 
int currentRepeat () const
 
bool setExternalAudio (const QString &file)
 setExternalAudio set audio track from an external audio stream. More...
 
QString externalAudio () const
 
const QVariantList & externalAudioTracks () const
 externalAudioTracks A list of QVariantMap. More...
 
const QVariantList & internalAudioTracks () const
 
bool setAudioStream (const QString &file, int n=0)
 setAudioStream set an external audio file and stream number as audio track More...
 
bool setAudioStream (int n)
 set audio/video/subtitle stream to n. More...
 
bool setVideoStream (int n)
 
const QVariantList & internalSubtitleTracks () const
 internalAudioTracks A list of QVariantMap. More...
 
bool setSubtitleStream (int n)
 
int currentAudioStream () const
 
int currentVideoStream () const
 
int currentSubtitleStream () const
 
int audioStreamCount () const
 
int videoStreamCount () const
 
int subtitleStreamCount () const
 
VideoCapturevideoCapture () const
 videoCapture Capture the current frame using videoCapture()->capture() More...
 
void play (const QString &path)
 play If isAsyncLoad() is true (default), play() will return immediately. More...
 
bool isPlaying () const
 
bool isPaused () const
 
State state () const
 state Player's playback state. More...
 
void setState (State value)
 
void addVideoRenderer (VideoRenderer *renderer)
 
void removeVideoRenderer (VideoRenderer *renderer)
 
void clearVideoRenderers ()
 
void setRenderer (VideoRenderer *renderer)
 
VideoRendererrenderer ()
 
QList< VideoRenderer * > videoOutputs ()
 
AudioOutputaudio ()
 audio AVPlayer always has an AudioOutput instance. More...
 
void setSpeed (qreal speed)
 setSpeed set playback speed. More...
 
qreal speed () const
 
void setInterruptTimeout (qint64 ms)
 setInterruptTimeout Emit error(usually network error) if open/read spends too much time. More...
 
qint64 interruptTimeout () const
 
void setInterruptOnTimeout (bool value)
 setInterruptOnTimeout More...
 
bool isInterruptOnTimeout () const
 
void setFrameRate (qreal value)
 setFrameRate Force the (video) frame rate to a given value. More...
 
qreal forcedFrameRate () const
 
const Statisticsstatistics () const
 
bool installFilter (AudioFilter *filter, int index=0x7FFFFFFF)
 installFilter Insert a filter at position 'index' of current filter list. More...
 
bool installFilter (VideoFilter *filter, int index=0x7FFFFFFF)
 
bool uninstallFilter (AudioFilter *filter)
 
bool uninstallFilter (VideoFilter *filter)
 
QList< Filter * > audioFilters () const
 
QList< Filter * > videoFilters () const
 
void setPriority (const QVector< VideoDecoderId > &ids)
 setPriority A suitable decoder will be applied when video is playing. More...
 
void setVideoDecoderPriority (const QStringList &names)
 setVideoDecoderPriority also can set in opt.priority More...
 
QStringList videoDecoderPriority () const
 
int brightness () const
 below APIs are deprecated. More...
 
int contrast () const
 
int hue () const
 
int saturation () const
 
void setOptionsForFormat (const QVariantHash &dict)
 
QVariantHash optionsForFormat () const
 
void setOptionsForAudioCodec (const QVariantHash &dict)
 
QVariantHash optionsForAudioCodec () const
 
void setOptionsForVideoCodec (const QVariantHash &dict)
 
QVariantHash optionsForVideoCodec () const
 
MediaEndAction mediaEndAction () const
 mediaEndAction The action at the end of media or when playback is stopped. More...
 
void setMediaEndAction (MediaEndAction value)
 

Static Public Member Functions

static const QStringList & supportedProtocols ()
 Supported input protocols. A static string list. More...
 

Protected Member Functions

virtual void timerEvent (QTimerEvent *)
 

Properties

bool relativeTimeMode
 
bool autoLoad
 
bool asyncLoad
 
qreal bufferProgress
 
bool seekable
 
qint64 duration
 
qint64 position
 
qint64 startPosition
 
qint64 stopPosition
 
qint64 repeat
 
int currentRepeat
 
qint64 interruptTimeout
 
bool interruptOnTimeout
 
int notifyInterval
 
int brightness
 
int contrast
 
int saturation
 
State state
 
QtAV::MediaStatus mediaStatus
 
QtAV::MediaEndAction mediaEndAction
 

Detailed Description

The AVPlayer class Preload:

player->setFile(...);
player->load();
do some thing...
player->play();

No preload:

player->setFile(...);
player->play();

Member Enumeration Documentation

The State enum The playback state.

It's different from MediaStatus. MediaStatus indicates media stream state

Enumerator
StoppedState 
PlayingState 
PausedState 

Start to play if it was stopped, or resume if it was paused.

Constructor & Destructor Documentation

QtAV::AVPlayer::AVPlayer ( QObject *  parent = 0)
explicit
QtAV::AVPlayer::~AVPlayer ( )

Member Function Documentation

qint64 QtAV::AVPlayer::absoluteMediaStartPosition ( ) const

Media stream property. The first timestamp in the media.

void QtAV::AVPlayer::addVideoRenderer ( VideoRenderer renderer)
void QtAV::AVPlayer::asyncLoadChanged ( )
signal
AudioOutput* QtAV::AVPlayer::audio ( )

audio AVPlayer always has an AudioOutput instance.

You can access or control audio output properties through audio(). To disable audio output, set audio()->setBackends(QStringList() << "null") before starting playback

Returns
QList<Filter*> QtAV::AVPlayer::audioFilters ( ) const
int QtAV::AVPlayer::audioStreamCount ( ) const
void QtAV::AVPlayer::autoLoadChanged ( )
signal
int QtAV::AVPlayer::brightness ( ) const

below APIs are deprecated.

TODO: setValue("key", value) or setOption("key", value) ? enum OptionKey { Brightness, ... VideoCodec, FilterOptions...} or use QString as keys?

void QtAV::AVPlayer::brightnessChanged ( int  val)
signal
qint64 QtAV::AVPlayer::buffered ( ) const
slot

buffered Current buffered value in msecs, bytes or packet count depending on bufferMode()

BufferMode QtAV::AVPlayer::bufferMode ( ) const
slot
qreal QtAV::AVPlayer::bufferProgress ( ) const
slot

bufferProgress How much the data buffer is currently filled.

From 0.0 to 1.0. Playback can start or resume only when the buffer is entirely filled.

void QtAV::AVPlayer::bufferProgressChanged ( qreal  )
signal
qreal QtAV::AVPlayer::bufferSpeed ( ) const
slot

bufferSpeed Bytes/s

Returns
0 if not buffering. >= 0 if buffering
int QtAV::AVPlayer::bufferValue ( ) const
slot
void QtAV::AVPlayer::clearVideoRenderers ( )
int QtAV::AVPlayer::contrast ( ) const
void QtAV::AVPlayer::contrastChanged ( int  val)
signal
int QtAV::AVPlayer::currentAudioStream ( ) const
int QtAV::AVPlayer::currentRepeat ( ) const
void QtAV::AVPlayer::currentRepeatChanged ( int  r)
signal
int QtAV::AVPlayer::currentSubtitleStream ( ) const
int QtAV::AVPlayer::currentVideoStream ( ) const
qint64 QtAV::AVPlayer::duration ( ) const
void QtAV::AVPlayer::durationChanged ( qint64  )
signal

durationChanged emit when media is loaded/unloaded

qreal QtAV::AVPlayer::durationF ( ) const
void QtAV::AVPlayer::error ( const QtAV::AVError e)
signal
QString QtAV::AVPlayer::externalAudio ( ) const
const QVariantList& QtAV::AVPlayer::externalAudioTracks ( ) const

externalAudioTracks A list of QVariantMap.

Using QVariantMap and QVariantList is mainly for QML support. [ {id: 0, file: abc.dts, language: eng, title: xyz}, ...] id: used for setAudioStream(id)

See also
externalAudioTracksChanged
void QtAV::AVPlayer::externalAudioTracksChanged ( const QVariantList &  tracks)
signal
QString QtAV::AVPlayer::file ( ) const
qreal QtAV::AVPlayer::forcedFrameRate ( ) const
int QtAV::AVPlayer::hue ( ) const
void QtAV::AVPlayer::hueChanged ( int  val)
signal
MediaIO* QtAV::AVPlayer::input ( ) const
bool QtAV::AVPlayer::installFilter ( AudioFilter filter,
int  index = 0x7FFFFFFF 
)

installFilter Insert a filter at position 'index' of current filter list.

If the filter is already installed, it will move to the correct index.

Parameters
indexA nagative index == size() + index. If index >= size(), append at last
Returns
false if audio/video thread is not ready. But the filter will be installed when thread is ready. false if already installed.
bool QtAV::AVPlayer::installFilter ( VideoFilter filter,
int  index = 0x7FFFFFFF 
)
const QVariantList& QtAV::AVPlayer::internalAudioTracks ( ) const
void QtAV::AVPlayer::internalAudioTracksChanged ( const QVariantList &  tracks)
signal

internalAudioTracksChanged Emitted when media is loaded.

See also
internalAudioTracks
void QtAV::AVPlayer::internalSubtitleHeaderRead ( const QByteArray &  codec,
const QByteArray &  data 
)
signal

internalSubtitleHeaderRead Emitted when internal subtitle is loaded.

Empty data if no data. codec is used by subtitle processors

void QtAV::AVPlayer::internalSubtitlePacketRead ( int  track,
const QtAV::Packet packet 
)
signal
const QVariantList& QtAV::AVPlayer::internalSubtitleTracks ( ) const

internalAudioTracks A list of QVariantMap.

Using QVariantMap and QVariantList is mainly for QML support. [ {id: 0, file: abc.dts, language: eng, title: xyz}, ...] id: used for setSubtitleStream(id)

See also
internalSubtitleTracksChanged; Different with external audio tracks, the external subtitle is supported by class Subtitle.
void QtAV::AVPlayer::internalSubtitleTracksChanged ( const QVariantList &  tracks)
signal
void QtAV::AVPlayer::interruptOnTimeoutChanged ( )
signal
qint64 QtAV::AVPlayer::interruptTimeout ( ) const
void QtAV::AVPlayer::interruptTimeoutChanged ( )
signal
bool QtAV::AVPlayer::isAsyncLoad ( ) const
bool QtAV::AVPlayer::isAutoLoad ( ) const
bool QtAV::AVPlayer::isInterruptOnTimeout ( ) const
bool QtAV::AVPlayer::isLoaded ( ) const
bool QtAV::AVPlayer::isPaused ( ) const
bool QtAV::AVPlayer::isPlaying ( ) const
bool QtAV::AVPlayer::isSeekable ( ) const
slot
bool QtAV::AVPlayer::load ( )
slot

load Load the current media set by setFile(); Can be used to reload a media and call play() later.

If already loaded, does nothing and return true. If async load, mediaStatus() becomes LoadingMedia and user should connect signal loaded() or mediaStatusChanged(QtAV::LoadedMedia) to a slot

Returns
true if success or already loaded.
void QtAV::AVPlayer::loaded ( )
signal
AVClock* QtAV::AVPlayer::masterClock ( )

masterClock setClockType() should call when playback started.

Returns
MediaEndAction QtAV::AVPlayer::mediaEndAction ( ) const

mediaEndAction The action at the end of media or when playback is stopped.

Default is quit threads and clear video renderers. If the flag MediaEndAction_KeepDisplay is set, the last video frame will keep displaying in video renderers. If MediaEndAction_Pause is set, you can still seek and resume the playback because no thread exits.

void QtAV::AVPlayer::mediaEndActionChanged ( QtAV::MediaEndAction  action)
signal
qint64 QtAV::AVPlayer::mediaStartPosition ( ) const

mediaStartPosition If relativeTimeMode() is true (default), it's 0.

Otherwise is the same as absoluteMediaStartPosition()

qreal QtAV::AVPlayer::mediaStartPositionF ( ) const
MediaStatus QtAV::AVPlayer::mediaStatus ( ) const
void QtAV::AVPlayer::mediaStatusChanged ( QtAV::MediaStatus  status)
signal
qint64 QtAV::AVPlayer::mediaStopPosition ( ) const
qreal QtAV::AVPlayer::mediaStopPositionF ( ) const
void QtAV::AVPlayer::muteChanged ( )
signal
int QtAV::AVPlayer::notifyInterval ( ) const
slot

The real notify interval. Always > 0.

void QtAV::AVPlayer::notifyIntervalChanged ( )
signal
QVariantHash QtAV::AVPlayer::optionsForAudioCodec ( ) const
QVariantHash QtAV::AVPlayer::optionsForFormat ( ) const
QVariantHash QtAV::AVPlayer::optionsForVideoCodec ( ) const
void QtAV::AVPlayer::pause ( bool  p = true)
slot
void QtAV::AVPlayer::paused ( bool  p)
signal
void QtAV::AVPlayer::play ( const QString &  path)

play If isAsyncLoad() is true (default), play() will return immediately.

Signals started() and stateChanged() will be emitted if media is loaded and playback starts.

void QtAV::AVPlayer::play ( )
slot

play Load media and start playback.

If current media is playing and media source is not changed, nothing to do. If media source is not changed, try to load (not in LoadingStatus or LoadedStatus) and start playback. If media source changed, reload and start playback.

qint64 QtAV::AVPlayer::position ( ) const
void QtAV::AVPlayer::positionChanged ( qint64  position)
signal
bool QtAV::AVPlayer::relativeTimeMode ( ) const

relativeTimeMode true (default): mediaStartPosition() is always 0.

All time related API, for example setPosition(), position() and positionChanged() use relative time instead of real pts false: mediaStartPosition() is from media stream itself, same as absoluteMediaStartPosition() To get real start time, use statistics().start_time. Or setRelativeTimeMode(false) first but may affect playback when playing.

void QtAV::AVPlayer::relativeTimeModeChanged ( )
signal
void QtAV::AVPlayer::removeVideoRenderer ( VideoRenderer renderer)
VideoRenderer* QtAV::AVPlayer::renderer ( )
int QtAV::AVPlayer::repeat ( ) const
void QtAV::AVPlayer::repeatChanged ( int  r)
signal
int QtAV::AVPlayer::saturation ( ) const
void QtAV::AVPlayer::saturationChanged ( int  val)
signal
void QtAV::AVPlayer::seek ( qreal  r)
slot
void QtAV::AVPlayer::seek ( qint64  pos)
slot
void QtAV::AVPlayer::seekableChanged ( )
signal
void QtAV::AVPlayer::seekBackward ( )
slot
void QtAV::AVPlayer::seekFinished ( qint64  position)
signal

seekFinished If there is a video stream currently playing, emitted when video seek is finished.

If only an audio stream is playing, emitted when audio seek is finished. The position() is the master clock value, It can be very different from video timestamp at this time.

Parameters
positionThe video or audio timestamp when seek is finished
void QtAV::AVPlayer::seekForward ( )
slot
SeekType QtAV::AVPlayer::seekType ( ) const
slot
void QtAV::AVPlayer::setAsyncLoad ( bool  value = true)

setAsyncLoad async load is enabled by default

bool QtAV::AVPlayer::setAudioStream ( const QString &  file,
int  n = 0 
)

setAudioStream set an external audio file and stream number as audio track

Parameters
fileexternal audio file. set empty to use internal audio tracks
naudio stream number n=0, 1, .... n<0: disable audio thread
Returns
false if fail
bool QtAV::AVPlayer::setAudioStream ( int  n)

set audio/video/subtitle stream to n.

n=0, 1, 2..., means the 1st, 2nd, 3rd audio/video/subtitle stream If n < 0, there will be no audio thread and sound/ If a new file is set(except the first time) then a best stream will be selected. If the file not changed, e.g. replay, then the stream not change return: false if stream not changed, not valid TODO: rename to track instead of stream

setAudioStream Set audio stream number in current media or external audio file

void QtAV::AVPlayer::setAutoLoad ( bool  value = true)

setAutoLoad true: current media source changed immediatly and stop current playback if new media source is set.

status becomes LoadingMedia=>LoadedMedia before play( and BufferedMedia when playing?) false: Default is false

void QtAV::AVPlayer::setBrightness ( int  val)
slot
void QtAV::AVPlayer::setBufferMode ( BufferMode  mode)
slot
void QtAV::AVPlayer::setBufferValue ( qint64  value)
slot

setBufferValue Ensure the buffered msecs/bytes/packets in queue is at least the given value before playback starts.

Set before playback starts.

Parameters
value<0: auto; BufferBytes: bytes, BufferTime: msecs, BufferPackets: packets count
void QtAV::AVPlayer::setContrast ( int  val)
slot
bool QtAV::AVPlayer::setExternalAudio ( const QString &  file)

setExternalAudio set audio track from an external audio stream.

this will try to load the external audio and select the 1st audio stream. If no error happens, the external audio stream will be set to current audio track. If external audio stream <0 before play, stream is auto selected You have to manually empty value to unload the external audio!

Parameters
fileexternal audio file path. Set empty to use internal audio tracks. TODO: reset stream number if switch to internal
Returns
true if no error happens
void QtAV::AVPlayer::setFile ( const QString &  path)

setFile TODO: Set current media source if current media is invalid or auto load is enabled.

Otherwise set as the pendding media and it becomes the current media if the next load(), play() is called

Parameters
path
void QtAV::AVPlayer::setFrameRate ( qreal  value)

setFrameRate Force the (video) frame rate to a given value.

Call it before playback start. If frame rate is set to a valid value(>0), the clock type will be set to User configuration of AVClock::ClockType and autoClock will be ignored.

Parameters
value<=0: ignore the value. normal playback ClockType and AVCloc >0: force to a given (video) frame rate
void QtAV::AVPlayer::setHue ( int  val)
slot
void QtAV::AVPlayer::setInput ( MediaIO in)

setInput Play media stream from custom MediaIO.

AVPlayer's demuxer takes the ownership. Call it when player is stopped.

void QtAV::AVPlayer::setInterruptOnTimeout ( bool  value)

setInterruptOnTimeout

Parameters
value
void QtAV::AVPlayer::setInterruptTimeout ( qint64  ms)

setInterruptTimeout Emit error(usually network error) if open/read spends too much time.

If isInterruptOnTimeout() is true, abort current operation and stop playback

Parameters
msmilliseconds. <0: never interrupt.TODO: rename to timeout
void QtAV::AVPlayer::setIODevice ( QIODevice *  device)

setIODevice Play media stream from QIODevice.

AVPlayer does not take the ownership. You have to manage device lifetime.

void QtAV::AVPlayer::setMediaEndAction ( MediaEndAction  value)
void QtAV::AVPlayer::setNotifyInterval ( int  msec)
slot

setNotifyInterval The interval at which progress will update

Parameters
msec<=0: auto and compute internally depending on duration and fps
void QtAV::AVPlayer::setOptionsForAudioCodec ( const QVariantHash &  dict)
See also
AVDecoder::setOptions() example: QVariantHash opt, vaopt, ffopt; vaopt["display"] = "X11"; opt["vaapi"] = vaopt; // only apply for va-api decoder ffopt["vismv"] = "pf"; opt["ffmpeg"] = ffopt; // only apply for ffmpeg software decoder player->setOptionsForVideoCodec(opt);
void QtAV::AVPlayer::setOptionsForFormat ( const QVariantHash &  dict)
See also
AVDemuxer::setOptions() example: QVariantHash opt; opt["rtsp_transport"] = "tcp" player->setOptionsForFormat(opt);
void QtAV::AVPlayer::setOptionsForVideoCodec ( const QVariantHash &  dict)
void QtAV::AVPlayer::setPosition ( qint64  position)
slot

setPosition equals to seek(qreal) position < 0: 0

Parameters
positionin ms
void QtAV::AVPlayer::setPriority ( const QVector< VideoDecoderId > &  ids)

setPriority A suitable decoder will be applied when video is playing.

The decoder does not change in current playback if no decoder is found. If not playing or no decoder found, the decoder will be changed at the next playback

Parameters
ids
void QtAV::AVPlayer::setRelativeTimeMode ( bool  value)
slot
void QtAV::AVPlayer::setRenderer ( VideoRenderer renderer)
void QtAV::AVPlayer::setRepeat ( int  max)
slot

setRepeat Repeat max times between startPosition() and endPosition().

It's reset if playback is stopped. max==0: no repeat max<0: infinity. std::numeric_limits<int>::max();

Parameters
max
void QtAV::AVPlayer::setSaturation ( int  val)
slot
void QtAV::AVPlayer::setSeekType ( SeekType  type)
slot
void QtAV::AVPlayer::setSpeed ( qreal  speed)

setSpeed set playback speed.

Parameters
speedspeed > 0. 1.0: normal speed TODO: playbackRate
void QtAV::AVPlayer::setStartPosition ( qint64  pos)
slot

startPosition Used to repeat from startPosition() to endPosition().

You can also start to play at a given position

player->setStartPosition();
player->play("some video");

pos < 0: equals duration()+pos pos == 0, means start at the beginning of media stream pos > media end position, or pos > normalized stopPosition(): undefined

void QtAV::AVPlayer::setState ( State  value)
void QtAV::AVPlayer::setStopPosition ( qint64  pos = std::numeric_limits< qint64 >::max())
slot

stopPosition pos > mediaStopPosition(): mediaStopPosition() pos < 0: duration() + pos With the default value, the playback will not stop until the end of media (including dynamically changed media duration, e.g.

recording video)

bool QtAV::AVPlayer::setSubtitleStream ( int  n)
void QtAV::AVPlayer::setTimeRange ( qint64  start,
qint64  stop = std::numeric_limits< qint64 >::max() 
)
slot

setTimeRange Set startPosition and stopPosition.

Make sure start <= stop.

void QtAV::AVPlayer::setVideoDecoderPriority ( const QStringList &  names)

setVideoDecoderPriority also can set in opt.priority

Parameters
namesthe video decoder name list in priority order. Name can be "FFmpeg", "CUDA", "DXVA", "D3D11", "VAAPI", "VDA", "VideoToolbox", case insensitive
bool QtAV::AVPlayer::setVideoStream ( int  n)
void QtAV::AVPlayer::sourceChanged ( )
signal
qreal QtAV::AVPlayer::speed ( ) const
void QtAV::AVPlayer::speedChanged ( qreal  speed)
signal
void QtAV::AVPlayer::started ( )
signal

started Emitted when playback is started.

Some functions that control playback should be called after playback is started, otherwise they won't work, e.g. setPosition(), pause(). stop() can be called at any time.

qint64 QtAV::AVPlayer::startPosition ( ) const
void QtAV::AVPlayer::startPositionChanged ( qint64  position)
signal
State QtAV::AVPlayer::state ( ) const

state Player's playback state.

Default is StoppedState. setState() is a replacement of play(), stop(), pause(bool)

Returns
void QtAV::AVPlayer::stateChanged ( QtAV::AVPlayer::State  state)
signal
const Statistics& QtAV::AVPlayer::statistics ( ) const
void QtAV::AVPlayer::stepBackward ( )
slot

stepBackward Play the previous frame and pause.

Currently only support the previous decoded frames

void QtAV::AVPlayer::stepForward ( )
slot

stepForward Play the next frame and pause

void QtAV::AVPlayer::stop ( )
slot

stop Stop playback.

It blocks current thread until the playback is stopped. Will emit signal stopped(). startPosition(), stopPosition(), repeat() are reset

void QtAV::AVPlayer::stopped ( )
signal
void QtAV::AVPlayer::stoppedAt ( qint64  position)
signal
qint64 QtAV::AVPlayer::stopPosition ( ) const

stopPosition: the position at which player should stop playing

Returns
If media stream is not a local file, stopPosition()==max value of qint64
void QtAV::AVPlayer::stopPositionChanged ( qint64  position)
signal
void QtAV::AVPlayer::subtitleStreamChanged ( int  value)
signal
int QtAV::AVPlayer::subtitleStreamCount ( ) const
static const QStringList& QtAV::AVPlayer::supportedProtocols ( )
static

Supported input protocols. A static string list.

virtual void QtAV::AVPlayer::timerEvent ( QTimerEvent *  )
protectedvirtual
void QtAV::AVPlayer::togglePause ( )
slot
bool QtAV::AVPlayer::uninstallFilter ( AudioFilter filter)
bool QtAV::AVPlayer::uninstallFilter ( VideoFilter filter)
void QtAV::AVPlayer::updateClock ( qint64  msecs)
slot
VideoCapture* QtAV::AVPlayer::videoCapture ( ) const

videoCapture Capture the current frame using videoCapture()->capture()

See also
VideoCapture
QStringList QtAV::AVPlayer::videoDecoderPriority ( ) const
QList<Filter*> QtAV::AVPlayer::videoFilters ( ) const
QList<VideoRenderer*> QtAV::AVPlayer::videoOutputs ( )
int QtAV::AVPlayer::videoStreamCount ( ) const

Property Documentation

bool QtAV::AVPlayer::asyncLoad
readwrite
bool QtAV::AVPlayer::autoLoad
readwrite
int QtAV::AVPlayer::brightness
readwrite
qreal QtAV::AVPlayer::bufferProgress
read
int QtAV::AVPlayer::contrast
readwrite
int QtAV::AVPlayer::currentRepeat
read
qint64 QtAV::AVPlayer::duration
read
bool QtAV::AVPlayer::interruptOnTimeout
readwrite
qint64 QtAV::AVPlayer::interruptTimeout
readwrite
QtAV::MediaEndAction QtAV::AVPlayer::mediaEndAction
readwrite
QtAV::MediaStatus QtAV::AVPlayer::mediaStatus
read
int QtAV::AVPlayer::notifyInterval
readwrite
qint64 QtAV::AVPlayer::position
readwrite
bool QtAV::AVPlayer::relativeTimeMode
readwrite
qint64 QtAV::AVPlayer::repeat
readwrite
int QtAV::AVPlayer::saturation
readwrite
bool QtAV::AVPlayer::seekable
read
qint64 QtAV::AVPlayer::startPosition
readwrite
State QtAV::AVPlayer::state
readwrite
qint64 QtAV::AVPlayer::stopPosition
readwrite

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