The VideoPlayer widget is used to perform playback of video. 更多...
| 头: | #include <Phonon/VideoPlayer> |
| Since: | Qt 4.4 |
| 继承: | QWidget |
| VideoPlayer (Phonon::Category category , QWidget * parent = 0) | |
| VideoPlayer (QWidget * parent = 0) | |
| ~VideoPlayer () | |
| AudioOutput * | audioOutput () const |
| qint64 | currentTime () const |
| bool | isPaused () const |
| bool | isPlaying () const |
| MediaObject * | mediaObject () const |
| qint64 | totalTime () const |
| VideoWidget * | videoWidget () const |
| float | volume () const |
| void | load (const Phonon::MediaSource & source ) |
| void | pause () |
| void | play (const Phonon::MediaSource & source ) |
| void | play () |
| void | seek (qint64 ms ) |
| void | setVolume (float volume ) |
| void | stop () |
| void | finished () |
The VideoPlayer widget is used to perform playback of video.
采用 VideoPlayer you can get results quickly and easily. You can do the standard playback tasks like play (), pause (),和 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 ,和 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.
Note also that most of the functions in this class are asynchronous. For instance, a media source may not play immediately after you call the play () 函数。
A play and forget code example:
VideoPlayer *player = new VideoPlayer(Phonon::VideoCategory, parentWidget); connect(player, SIGNAL(finished()), player, SLOT(deleteLater())); player->play(url);
另请参阅 Phonon 模块 and MediaObject .
构造新的 VideoPlayer instance with the specified parent .
category is the category used for the audio output device.
Constructs a new video widget with a parent 使用 Phonon::VideoCategory as its category.
parent The QObject parent.
On destruction the playback is stopped, also the audio output is removed so that the desktop mixer will not show the application anymore. If you need a persistent audio output don't use VideoPlayer but MediaObject , VideoPath and VideoOutput.
Returns the audio output object being used by the player.
Get the current time (in milliseconds) of the file currently being played.
[signal]
void
VideoPlayer::
finished
()
This signal is emitted when the playback finished.
Returns true if it is currently paused; otherwise returns false if it is currently playing or stopped.
Returns true if it is currently playing; otherwise returns false if it is currently stopped or paused
[slot]
void
VideoPlayer::
load
(const
Phonon::MediaSource
&
source
)
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::setCurrentSource ().
Returns the media object being used by the player.
The media object can be accessed directly instead of using the VideoPlayer s convenience functions, e.g., play () 和 stop (). It is also possible to give the object to other Phonon widgets, e.g., a SeekSlider 或 VolumeSlider .
另请参阅 Phonon::SeekSlider and Phonon::MediaObject .
[slot]
void
VideoPlayer::
pause
()
Pauses the playback.
另请参阅 MediaObject::pause ().
[slot]
void
VideoPlayer::
play
(const
Phonon::MediaSource
&
source
)
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.
[slot]
void
VideoPlayer::
play
()
Continues playback of paused media. Restarts playback of a stopped (or newly loaded) media.
另请参阅 MediaObject::play () 和 play ().
[slot]
void
VideoPlayer::
seek
(
qint64
ms
)
Seeks to the requested time. Note that the backend is free to ignore the seek request if the media source isn't seekable; you can check this by asking the media object of the VideoPlayer .
player->mediaObject()->isSeekable();
The ms parameter is the time in milliseconds from the start of the media.
The call is asynchronous, so currentTime () can still be the old value right after this method was called. If all you need is a slider that shows the current position and allows the user to seek, use the class SeekSlider .
另请参阅 MediaObject::seek (), MediaObject::isSeekable (),和 mediaObject ().
[slot]
void
VideoPlayer::
setVolume
(
float
volume
)
设置 volume of the output as voltage factor.
1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0%
另请参阅 volume ().
[slot]
void
VideoPlayer::
stop
()
Stops the playback.
另请参阅 MediaObject::stop ().
Get the total time (in milliseconds) of the file currently being played.
Returns the video widget being used by the player.
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%
另请参阅 setVolume ().