|  | Home · All Classes · Modules

# Phonon.VideoPlayer Class Reference
[phonon module]

The VideoPlayer widget is used to perform playback of video. More...

Inherits QWidget.

### Methods

- __init__ (self, Category category, QWidget parent = None)
- AudioOutput audioOutput (self)
- long currentTime (self)
- bool isPaused (self)
- bool isPlaying (self)
- load (self, MediaSource source)
- MediaObject mediaObject (self)
- pause (self)
- play (self, MediaSource source)
- play (self)
- seek (self, long ms)
- setVolume (self, float volume)
- stop (self)
- long totalTime (self)
- VideoWidget videoWidget (self)
- float volume (self)

### Qt Signals

- void finished ()

## Detailed Description

The VideoPlayer widget is used to perform playback of video.

With VideoPlayer you can get results quickly and easily. You can do the standard playback tasks like play(), pause(), and stop(), but also set a playback volume and seek - if the media and backend supports seeking.

VideoPlayer is provided for convenience and removes the need to create a media graph with a MediaObject, AudioOutput, and VideoWidget. If you need functionality not supported by the player, you can build this graph yourself.

Keep in mind that when the VideoPlayer instance is deleted the playback will stop.

A play and forget code example:

     VideoPlayer *player = new VideoPlayer(Phonon.VideoCategory, parentWidget);
     connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
     player->play(url);

Author: Matthias Kretz <kretz@kde.org>

## Method Documentation

### VideoPlayer.__init__ (self, Category category, QWidget parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new VideoPlayer instance with the specified parent.

category is the category used for the audio output device.

### AudioOutput VideoPlayer.audioOutput (self)

Returns the audio output object being used by the player.

### long VideoPlayer.currentTime (self)

Get the current time (in milliseconds) of the file currently being played.

### bool VideoPlayer.isPaused (self)

Returns true if it is currently paused; otherwise returns false if it is currently playing or stopped

### bool VideoPlayer.isPlaying (self)

Returns true if it is currently playing; otherwise returns false if it is currently stopped or paused

### VideoPlayer.load (self, MediaSource source)

This method is also a Qt slot with the C++ signature `void load(const Phonon::MediaSource&)`.

Starts pre-loading the media data from the specified source and filling audio buffers in the backend.

When there's already a media playing (or paused) it will be stopped (the finished signal will not be emitted).

### MediaObject VideoPlayer.mediaObject (self)

Returns the media object being used by the player.

You can manipulate the object, for instance, use it for a SeekSlider.

See also Phonon.SeekSlider and Phonon.MediaObject.

### VideoPlayer.pause (self)

This method is also a Qt slot with the C++ signature `void pause()`.

Pauses the playback.

### VideoPlayer.play (self, MediaSource source)

This method is also a Qt slot with the C++ signature `void play(const Phonon::MediaSource&)`.

Plays the media from the given source. Starts playback as fast as possible. This can take a considerable time depending on the URL and the backend.

If you need low latency between calling play() and the sound actually starting to play on your output device you need to use MediaObject and be able to set the URL before calling play(). Note that

     audioPlayer->load(url);
     audioPlayer->play();

doesn't make a difference: the application should be idle between the load and play calls so that the backend can start preloading the media and fill audio buffers.

### VideoPlayer.play (self)

This method is also a Qt slot with the C++ signature `void play()`.

This is an overloaded member function, provided for convenience.

Continues playback of paused media. Restarts playback of a stopped media.

### VideoPlayer.seek (self, long ms)

This method is also a Qt slot with the C++ signature `void seek(qint64)`.

Seeks to the requested time. Note that the backend is free to ignore the seek request if the media source isn't seekable.

The ms parameter is the time in milliseconds from the start of the media.

### VideoPlayer.setVolume (self, float volume)

This method is also a Qt slot with the C++ signature `void setVolume(float)`.

Sets the volume of the output as voltage factor.

1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0%

See also volume().

### VideoPlayer.stop (self)

This method is also a Qt slot with the C++ signature `void stop()`.

Stops the playback.

### long VideoPlayer.totalTime (self)

Get the total time (in milliseconds) of the file currently being played.

### VideoWidget VideoPlayer.videoWidget (self)

### float VideoPlayer.volume (self)

This is the current volume of the output as voltage factor.

1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0%

See also setVolume().

## Qt Signal Documentation

### void finished ()

This signal is emitted when the playback finished.