Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

VideoPlayer Class Reference

(Phonon::VideoPlayer)

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

 #include <Phonon/VideoPlayer>

Inherits: QWidget.

This class was introduced in Qt 4.4.

Public Functions

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
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Public Slots

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 ()
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

void finished ()

Additional Inherited Members

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

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.

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() function.

A play and forget code example:

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

See also Phonon Module and MediaObject.

Member Function Documentation

VideoPlayer::VideoPlayer ( Phonon::Category category, QWidget * parent = 0 )

Constructs a new VideoPlayer instance with the specified parent.

category is the category used for the audio output device.

VideoPlayer::VideoPlayer ( QWidget * parent = 0 )

Constructs a new video widget with a parent using Phonon::VideoCategory as its category.

parent The QObject parent.

VideoPlayer::~VideoPlayer ()

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.

AudioOutput * VideoPlayer::audioOutput () const

Returns the audio output object being used by the player.

qint64 VideoPlayer::currentTime () const

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

void VideoPlayer::finished () [signal]

This signal is emitted when the playback finished.

bool VideoPlayer::isPaused () const

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

bool VideoPlayer::isPlaying () const

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

void VideoPlayer::load ( const Phonon::MediaSource & source ) [slot]

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).

See also MediaObject::setCurrentSource().

MediaObject * VideoPlayer::mediaObject () const

Returns the media object being used by the player.

The media object can be accessed directly instead of using the VideoPlayers convenience functions, e.g., play() and stop(). It is also possible to give the object to other Phonon widgets, e.g., a SeekSlider or a VolumeSlider.

See also Phonon::SeekSlider and Phonon::MediaObject.

void VideoPlayer::pause () [slot]

Pauses the playback.

See also MediaObject::pause().

void VideoPlayer::play ( const Phonon::MediaSource & source ) [slot]

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.

void VideoPlayer::play () [slot]

Continues playback of paused media. Restarts playback of a stopped (or newly loaded) media.

See also MediaObject::play() and play().

void VideoPlayer::seek ( qint64 ms ) [slot]

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.

See also MediaObject::seek(), MediaObject::isSeekable(), and mediaObject().

void VideoPlayer::setVolume ( float volume ) [slot]

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().

void VideoPlayer::stop () [slot]

Stops the playback.

See also MediaObject::stop().

qint64 VideoPlayer::totalTime () const

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

VideoWidget * VideoPlayer::videoWidget () const

Returns the video widget being used by the player.

float VideoPlayer::volume () const

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().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Labs au hasard

Logo

La folie est de mettre en forme le même texte

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web