Creating and Preparing a Video Player

This tutorial describes how to get started with the video player utility.

Purpose

The purpose of this tutorial is to show you how to create a new video player utility and prepare it for playing video data.

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 Utility

The following tasks will be covered in this tutorial:

Creating a Utility Object

The high level steps to construct a video player utility object are shown here:

Opening a Video Source

The high level steps to open a video source are shown here:

  1. Unlike CMdaAudioPlayerUtility, video clips cannot be opened during instantiation of the CVideoPlayerUtility class. Hence all the video clips must be opened using one of the following open functions:

    • From a file

      OpenFileL(const TDesC& aFileName, TUid aControllerUid=KNullUid);
      

      This method opens the video clip from a file. It uses an optionally specified plugin in the argument to load a controller. If no controller plugin is specified, it searches through the list of available plugins and attempts to use each one until successful or the end of the list is reached.

      Note: There is also another method to open a video clip from a file. It is strongly recommended to use this method.

      OpenFileL(const TMMSource& aSource, TUid aControllerUid);

      Where aSource is a filename or an open handle to a file containing the video clip and aControllerUid is an optionally specified plugin. If specified, it will force the video player to use the controller with the given UID. If no controller plugin is specified, this function searches through a list of all available plugins and attempts to use each one until successful or the end of the list is reached.

    • From a descriptor

      OpenDesL(const TDesC8& aDescriptor, TUid aControllerUid=KNullUid);

      This method opens the video clip from a descriptor. It opens the video clip contained as binary data in a descriptor using an optionally specified plugin in the argument to load a controller. If no controller is specified, it searches through the list of available plugins and attempts to use each one until successful or the end of the list is reached.

    • From an URL

      OpenUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8, TUid aControllerUid=KNullUid);

      This method opens the video clip from the specified URL and identified by the MIME type. In addition a plugin can be specified if necessary. If no controller plugin is specified, this function searches through a list of all available plugins and attempts to use each one until successful or the end of the list is reached.

  2. As the opening of the video clip is complete, successfully or otherwise, the callback function MVideoPlayerUtilityObserver::MvpuoOpenComplete() is called. This notifies the client whether the video clip was successfully opened or not.

Note: To open and automatically play video clips, use the following open functions:

OpenAndPlayFileL(const TDesC& aFileName, TUid aControllerUid=KNullUid);

OpenAndPlayDesL(const TDesC8& aDescriptor, TUid aControllerUid=KNullUid);

OpenAndPlayUrlL(const TDesC& aUrl, TInt aIapId = KUseDefaultIap, const TDesC8& aMimeType=KNullDesC8, TUid aControllerUid=KNullUid);

Preparing to Play

The high level steps to prepare to play video are shown here:

  1. Once the video data is ready, call the CVideoPlayerUtility::Prepare() function.

    void CVideoPlayerUtility::Prepare()
        {
        iBody->Prepare();
        }
  2. When the client receives the MVideoPlayerUtilityObserver::MvpuoPrepareComplete() callback, the video player utility will be in configured state.