|  | Home · All Classes · Modules

# Phonon.VideoWidget Class Reference
[phonon module]

The VideoWidget class provides a widget that is used to display video. More...

Inherits QWidget and AbstractVideoOutput.

### Types

- enum AspectRatio { AspectRatioAuto, AspectRatioWidget, AspectRatio4_3, AspectRatio16_9 }
- enum ScaleMode { FitInView, ScaleAndCrop }

### Methods

- __init__ (self, QWidget parent = None)
- AspectRatio aspectRatio (self)
- float brightness (self)
- float contrast (self)
- enterFullScreen (self)
- bool event (self, QEvent)
- exitFullScreen (self)
- float hue (self)
- mouseMoveEvent (self, QMouseEvent)
- float saturation (self)
- ScaleMode scaleMode (self)
- setAspectRatio (self, AspectRatio)
- setBrightness (self, float value)
- setContrast (self, float value)
- setFullScreen (self, bool fullscreen)
- setHue (self, float value)
- setSaturation (self, float value)
- setScaleMode (self, ScaleMode)
- QImage snapshot (self)

## Detailed Description

The VideoWidget class provides a widget that is used to display video.

The VideoWidget class renders the video of a media stream on a QWidget. It is connected to the MediaObject, of which video stream it should render. You connect the two objects using the Phonon.createPath() function.

The widget has some possibilities to manipulate the video stream. You can change the brightness(), hue(), saturation(), and contrast().

Resizing of the video is handled automatically, but you can affect the way the video is resized with the aspectRatio and scaleMode properties. By default, the widget will use the aspect ratio of the video stream itself.

The video widget takes the size of the video when it receives a new video stream (i.e., when a new MediaSource is set on the MediaObject to which it is connected). If you need to know the size of the video, you can call sizeHint() after the video has been loaded (i.e., after the MediaObject leaves the LoadingState).

It is also possible to go to full screen mode.

A typical example of usage follows below:

     MediaObject *media = new MediaObject(parent);
     VideoWidget *vwidget = new VideoWidget(parent);
     Phonon.createPath(media, vwidget);

## Type Documentation

### VideoWidget.AspectRatio

Defines the width:height to be used for the video.

Constant | Value | Description
--- | --- | ---
`Phonon.VideoWidget.AspectRatioAuto` | `0` | Let the decoder find the aspect ratio automatically from the media file (this is the default).
`Phonon.VideoWidget.AspectRatioWidget` | `1` | Fits the video into the widget making the aspect ratio depend solely on the size of the widget. This way the aspect ratio is freely resizeable by the user.
`Phonon.VideoWidget.AspectRatio4_3` | `2` | Make width/height == 4/3, which is the old TV size and monitor size (1024/768 == 4/3). (4:3)
`Phonon.VideoWidget.AspectRatio16_9` | `3` | Make width/height == 16/9, which is the size of most current media. (16:9)

### VideoWidget.ScaleMode

The ScaleMode enum describes how to treat aspect ratio during resizing of video.

Constant | Value | Description
--- | --- | ---
`Phonon.VideoWidget.FitInView` | `0` | The video will be fitted to fill the view keeping aspect ratio.
`Phonon.VideoWidget.ScaleAndCrop` | `1` | The video is scaled

## Method Documentation

### VideoWidget.__init__ (self, QWidget parent = None)

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

Constructs a new video widget with the specified parent.

### AspectRatio VideoWidget.aspectRatio (self)

### float VideoWidget.brightness (self)

### float VideoWidget.contrast (self)

### VideoWidget.enterFullScreen (self)

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

Convenience slot, calling setFullScreen(true)

### bool VideoWidget.event (self, QEvent)

Reimplemented from QObject.event().

### VideoWidget.exitFullScreen (self)

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

Convenience slot, calling setFullScreen(false)

### float VideoWidget.hue (self)

### VideoWidget.mouseMoveEvent (self, QMouseEvent)

Reimplemented from QWidget.mouseMoveEvent().

### float VideoWidget.saturation (self)

### ScaleMode VideoWidget.scaleMode (self)

### VideoWidget.setAspectRatio (self, AspectRatio)

This method is also a Qt slot with the C++ signature `void setAspectRatio(Phonon::VideoWidget::AspectRatio)`.

### VideoWidget.setBrightness (self, float value)

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

### VideoWidget.setContrast (self, float value)

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

### VideoWidget.setFullScreen (self, bool fullscreen)

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

### VideoWidget.setHue (self, float value)

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

### VideoWidget.setSaturation (self, float value)

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

### VideoWidget.setScaleMode (self, ScaleMode)

This method is also a Qt slot with the C++ signature `void setScaleMode(Phonon::VideoWidget::ScaleMode)`.

### QImage VideoWidget.snapshot (self)

Returns a snapshot of the current frame shown in the widget.

This function was introduced in Qt 4.7.