Configuring the Video Player

This tutorial describes how to configure the video player.

Purpose

The purpose of this tutorial is to show you how to make configuration adjustments to the video player.

Required Background

The Video Client Overview introduces the video client utilities.

Introduction

The video player utility is used to open, play, and obtain information from sampled video data. This functionality is implemented by the CVideoPlayerUtility class. The video data can be supplied either in a file, a descriptor or a URL.

Using Video Player

The following tasks will be covered in this tutorial:

Setting the Display Window

The high level steps to set the display window are shown here:

  • CVideoPlayerUtility::SetDisplayWindowL: This is used to provide the video controller with an area of display to render the current video frame. It can be represented pictorially as shown below:

    Figure: Video display regions

    The screeenRect specifies the area within the window provided for displaying the video image. This rectangle is in screen coordinates. The video frame will be fitted to this rectangle as best possible, while maintaining the original aspect ratio.

    The ClipRect specifies the region to draw. The drawn region will be the intersection between the ClipRect and the ScreenRect.

    A crop region is defined as a region in the source video frame. The cropped region is displayed in the center of the ScreenRect with the same scaling as if it was displayed as part of the whole image. This could be used to zoom in on a region by setting the crop region, and setting the scale factor to fill the WindowRect.

    void CPlayVideo::SetDisplayWindowL(RWsSession &aWs, CWsScreenDevice &aScreenDevice, RWindowBase &aWindow, const TRect &aWindowRect, const TRect &aClipRect)
        {
        iVideoUtility->SetDisplayWindowL(aWs, aScreenDevice, aWindow, aWindowRect, aClipRect);
        }
    

Querying and Setting the Volume

The current volume settings can be reported and set appropriately with the help of the following functions: :

  • CVideoPlayerUtility::Volume(): Returns the current playback volume for the audio track of the video clip.

    TInt CPlayVideo::Volume() 
        {
        return iVideoUtility->Volume();
        }
  • CVideoPlayerUtility::MaxVolume(): Returns the maximum volume that the audio track can support.

  • CVideoPlayerUtility::SetVolumeL(): This function allows the volume of the audio track of the video clip to be set. The volume can be changed before or during playback and comes to effect immediately. The volume can be set to a value anywhere between zero and the maximum permissible volume.

    TInt volume;
    
    volume = iVideoPlayer.MaxVolume(); \\Returns maximum volume
    void CPlayVideo::SetVolumeL(TInt aVolume) \\Set the audio volume
        {
        iVideoUtility->SetVolumeL(aVolume);
        } 
    
    //The volume must be a value between 0 and the value returned by the MaxVolume function.
    
    

Querying and Setting the Balance

The audio playback balance settings can be done using the following functions:

  • CVideoPlayerUtility::SetBalanceL(): This function sets the current playback balance for the audio track of the video clip. It can be any value between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.

    void CPlayVideo::SetBalanceL(TInt aBalance)
        {
        iVideoUtility->SetBalanceL(aBalance);
        }
  • CVideoPlayerUtility::Balance(): This function returns the current playback balance settings for the audio track of the video clip.

    TInt CPlayVideo::Balance() 
        {
        return iVideoUtility->Balance();    
        }

Querying and Setting the Priority

To set the priority for the playback to access the sound hardware, use the following methods:

  • PriorityL(): This function returns the current playback priority. This is used to arbitrate between multiple objects simultaneously trying to accesses the sound hardware.

  • SetPriorityL(): This function sets the playback priority.

    void CPlayVideo::SetPriorityL(TInt aPriority, TMdaPriorityPreference aPref)
        {
        iVideoUtility->SetPriorityL(aPriority, aPref);
        }

Querying and Setting the Bit and Frame Rate

The high level steps to query and set the bit and frame rate:

  • CVideoPlayerUtility::VideoBitRateL(): This function returns the bit rate of the video clip. This returns the video clip's bit rate in bits per second.

    TInt CPlayVideo::VideoBitRateL() 
        {
        return iVideoUtility->VideoBitRateL();
        }
  • CVideoPlayerUtility::VideoFrameRateL(): This function returns the video frame rate. This returns the video frame rate in frames per second.

    TReal32 CPlayVideo::VideoFrameRateL()
        {
        return iVideoUtility->VideoFrameRateL();
        }
  • CVideoPlayerUtility::SetVideoFrameRateL(): This function is used to set the number of video frames to be displayed per second.

    void CPlayVideo::SetVideoFrameRateL(TReal32 aFramesPerSecond)
        {
        iVideoUtility->SetVideoFrameRateL(aFramesPerSecond);
        }

Note: The presence of an audio track within a video clip can be determined using AudioEnabledL().

Querying and Setting the Current Playback Position

The current playback position can be queried and set using the following functions:

  • CVideoPlayerUtility::PositionL(): This function returns the current playback position. It returns the current position from the start of the clip in microseconds.

  • CVideoPlayerUtility::SetPositionL(): This function sets the position for the playback within the video clip to start.

    TTimeIntervalMicroSeconds pos;
    TTimeIntervalMicroSeconds CPlayVideo::PositionL() \\ retrieves the current playback position within the video clip
        {
        return iVideoUtility->PositionL();
        } 

Querying and Setting the MIME and Codec Type

This section explains the functions that reports and sets the MIME type and codecs for video and audio data that is already open. The functions are as stated below:

  • CVideoPlayerUtility::VideoFormatMimeType(): This returns the current MIME type of the video clip currently open.

    const TDesC8 & CPlayVideo::VideoFormatMimeType() 
        {
        return iVideoUtility->VideoFormatMimeType();
        }
  • The datatype of the audio track used by the video clip can be retrieved using and AudioTypeL().

    TFourCC CPlayVideo::AudioTypeL() \\retrieves the codecs used by audio track
        {
        return iVideoUtility->AudioTypeL();
        } 

See Also

Creating and Preparing a Video Player

Enabling/Disabling Audio or Video Playback Separately

Scaling Automatically

Controlling Video Playback

Fast Forwarding and Rewinding

Stepping Frames

Controlling the Video Controller Plugin