The UMSMoviePlayer object provides methods to play synchronized audio and video from movie files. It uses the generic base classes of UMSMovieFileReader, UMSVideoDecoder, UMSAudioDevice, and UMSImageWindow. Therefore, the UMSMoviePlayer object can be extended without code modifications to support new file formats, new decompression algorithms, new audio devices and new video display devices simply by the availability of new implementations of these base classes.
Ultimedia Services provides UMSMovieFIleReader object implementations for the AVI file format and for a fast file format. UMSVideoDecoder implementations are provided for Ultimotion, JPEG, RTV, and Indeo video compression. And various UMSAudioDevice implementations support the various audio devices used across supported systems.
To learn more about the UMSMoviePlayer object, see:
For introductory information, see Media Handler Objects.
To avoid name collision on defines, integer values have been captured as enumerated lists. The set of valid values from an enumerated list can vary with the application. The detailed method descriptions describe the valid or possible values for the specific use. The enumerated lists that are defined for this object are:
enum ReturnCode { Success, NoFile, NoFileObj, NoConfigObj, NoAlias, NoDevice, DeviceNotReady, InvalidState, WrongFormat, InvalidCuepoint, OutOfRange, Duplicate, CueLimit, FileError, InvalidFactor, InvalidCommand, WindowDefined, InvalidWindow, NoWindow, ColorMap, Failure, DecompressFail, NoEventPending, InvalidTrack, InvalidParam, InvalidTimeFmt, InvalidClass, MemoryError, EndOfFile, NoAudio, ValueChanged };-->
enum State { NotReadyState, ReadyState, PlayState, ScanState, FreezeState, PausePlayState, PauseScanState };
enum OnOff { Off, On };
enum Set clear { Clear, Set };
enum CueType { PlayCue, RecordCue };
enum AudioFormat { PCM, OtherAudioFormat };
enum BitsPerSample { Eight, Sixteen, OtherBitsPerSample };
enum TimeFormat { Msecs, Frames }
enum SourceType { LocalFile }
enum EventType { PlayComplete, Cuepoint, PositionAdvise, Error };
The movie player defines the following constants:
const unsigned long PLAY_COMPLETE = 0x00000001; const unsigned long CUE_POINT = 0x00000002; const unsigned long POSITION_ADVISE = 0x00000004; const unsigned long PLAYER_ERROR = 0x80000000;
Structures defined for the UMSMoviePlayer object include:
struct EventData { EventType type; unsigned long current_position; unsigned long specific; };
The player has seven possible states:
The following table illustrates the UMSMoviePlayer state diagram.
Movie Player States | ||||||
Not Ready | Ready | Play | Scan | Freeze | Pause Play/ Pause Scan | |
load | Ready1 | Ready | Ready | Ready | Ready | Ready |
open_audio | Ready1 | Ready | Play | Scan | Freeze | Pause Play/Scan |
set_window | Ready1 | Ready | Play | Scan | Freeze | Pause Play/Scan |
release_win- dow | NotReady | Ready2 | Play2 | Ready2 | Freeze2 | Pause Play/Scan 2 |
close_audio | Ready3 | Ready3 | Play3 | Scan | Pause Play3 | Pause Play/Scan3 |
cue | Error | Pause Play | Pause Play | Pause Play | Pause Play | Pause Play |
play | Error | Play | Play | Play | Play | Play |
scan4 | Error | Scan | Scan | Scan | Scan | Scan |
freeze | Error | Error | Freeze | Pause Scan | Freeze | Pause Play/Scan |
seek | NotReady | Ready | Ready | Ready | Ready | Ready |
pause | Error | Error | Pause Play | Pause Scan | Pause Play | Pause Play/Scan |
resume | Error | Error | Play | Scan | Play | Play/Scan |
stop | NotReady | Ready | Ready | Ready | Ready | Ready |
step | Error | Pause Play | Pause Play | Pause Scan | Pause Play | Pause Play/Scan |
1 open, load, and set_window are methods that can fulfill the last requirement to become Ready.
2 release_window when file has no audio causes NotReady state.
3 close_audio when no window is set causes NotReady state.
4 scan with no window set is an error.
The UMSMoviePlayer obtains a color map once the UMSMovie Player has received both the set_window and load (file) methods. You should then issue the get_color_map method to obtain the color map ID and install this color map. To create a colormap, the UMSMoviePlayer obtains entries 0-127 from the DefaultColormap and entries 128-255 from the UMSVideoDecoder. The contents of entries 128-255 changes across file loads if the movie's video format type changes (for example, Ultimotion to JPEG).
This method uses an alias to specify which audio device should be used by the movie player. The configuration object is accessed to relate the alias and device name. If an open is issued when a device has already been opened, the existing device is closed and the new device is opened.
This method specifies the pathname of the file to be opened in the path parameter. The UMSMoviePlayer uses an instance of the UMSMovieFileReader base class to access movie files. The specific implementation of the UMSMovieFileReader used is transparent to the UMSMoviePlayer. The methods of the UMSMovieFileReaderMClass object are used to instantiate the specific object. If the string parameter file_alias is NULL, the make_by_pathname method of UMSMovieFileReaderMClass is used to construct the specific object based on detection of the appropriate file type. If the string parameter path is not NULL, the make_by_alias method of UMSMovieFileReaderMClass is used to construct the specific object. This allows the application to override file type detection and request instantiation of a specific object via a UMSMovieFileReader file_type_alias. A successful load clears the existing cuepoints and displaces a previously opened file.
in string path | Specifies the pathname of the file to open |
This method closes the previously specified audio device. This method does not affect the state or location of the media file specified with the load method. If a window was set by way of set_window, the video continues playing; if not, the state becomes NotReady.
This method is used to start playback from the current position to the end of the file. When the end of file is reached, a PlayComplete event is issued. If repeat is not set on, the Pause state is entered at completion.
If repeat is set on, play continues with successive playing of the file (from beginning to end) with a PlayComplete event each time the end of the file is reached until play is explicitly stopped by a command (such as pause or stop).
InvalidState | Invalid state to accept play. |
This method plays from the current position and continues until the to position is reached, at which time a PlayComplete event is returned. If repeat is not set on, the Pause state is entered at completion.
If repeat is set on, play continues with successive playing of the segment (from the location at which playto was issued to the to location) generating a PlayComplete event each time the to location is reached until play is explicitly stopped by a command (such as pause or stop).
If the to position is beyond the end of the file, the command is rejected with an OutOfRange return code.
If the to location is before the current position, the player immediately issues the PlayComplete event, seeks to the to position, and pauses, regardless of whether repeat had been turned on or off.
in unsigned long to | Specifies the file location in the current time format to play to. |
InvalidState | The player state does not permit this command. |
OutOfRange | The to position specified is out of range. |
This method suspends playback or scanning. The device and file remain in an open state at the current location and cued for playing or scanning. Playing or scanning can resume by calling the play, scan, or resume methods.
InvalidState | The player cannot be paused from this state. |
This method resumes playing/scanning from a paused state. If already playing or scanning, Success is returned and the command is ignored. If the video was frozen with the freeze method, the video resumes at the position appropriate to the continuing audio track.
InvalidState | The player is not in a Pause, Play, or Freeze state. |
This method sets a cuepoint for playback. This is specified as a time offset from the beginning of the file. When the cuepoint is reached, a Cuepoint event is generated. The maximum number of cuepoints allowed is 20.
This method sets the position-change notification frequency. Only one frequency can be set. If the value of interval is zero it turns position advise off. The player uses the most current definition of interval. Position advise events are sent at the given interval if that event type is enabled.
in unsigned long interval | Specifies the position-change notification interval in units of the current time format. |
This method exits the play, or pause state and returns to the ready state.
InvalidState | The player is in an invalid state to accept stop. |
Seeks to the specified file location. The file location is specified in the current time format units. For more information, see set_time_format method.
in unsigned long location | Specifies the target seek location in current time units. |
This method prerolls the media for play. The player enters a pause state.
in CueType type | Specifies PlayCue or RecordCue. Only PlayCue is valid |
InvalidState | Player cannot accept cue from current state. |
This method returns the currently loaded file name and opened device alias name as null terminated strings. The pointers are passed by the caller and must have space to hold the name strings. If the device or filename has not been defined, a null is returned at the pointer location.
These returned string parameters break the general convention of Ultimedia Services objects of returning strings declared as out rather than inout. In this particular case, the pathname and the initial audio device alias has been supplied; the returned size does not exceed the initialized size.
This method changes the level of audio as a percentage of the maximum audio. If the integer in level field is greater than 100, then 100 is used as the volume. The time argument is provided to permit fade in and fade out capability but is not implemented in this release.
in long level | Specifies the requested volume level as a value from 0 to 100. |
in unsigned long time | Specifies the time delay over which the volume adjustment is made. |
OutOfRange | A parameter was out of range. |
This method changes the balance of the audio. The time argument permits the balance to be modified over a time period but is not implemented in this release.
in long level | The requested balance from -100 to 100. A value of 0 represents the balance center point. |
in unsigned long time | Specifies the time delay over which the balance adjustment is made. |
OutOfRange | A parameter was out of range. |
This method returns the current volume level.
The volume as an integer from 0 to 100.
This method returns the current balance level.
The balance as an integer from -100 to 100.
The number of channels in the next frame of audio data for the selected audio track in the loaded movie file. A value of one indicates mono data, while a value of two indicates stereo. If no file has been opened, the ReturnCode value is NoFile.
inout long channels | The number of channels for the selected audio data is returned. |
This method gets the current state of the player.
A value from the State enumeration list indicating the current state.
Specifies the setting of a mask to enable or disable reporting of maskable events. The default is for these bits to be 1 and not masked. Note that PLAY_COMPLETE and PLAYER_ERROR are not maskable.
in unsigned long event_mask | An OR'ed set of bit flags enabling the corresponding events. CUEPOINT and POSITION_ADVISE are maskable events. |
Returns the current event_mask indicating which events are enabled.
The current event mask. This is the bit OR set of:
PLAY_COMPLETE CUEPOINT POSITION_ADVISE PLAYER_ERROR
Returns the next event in the space provided by event_data. It blocks if no event is available. The event type is available in the event data structure and is also returned.
If an event is not available and a play, freeze, or scan is not in progress, an EventType error is returned. This prevents the possibility of indefinitely blocking.
Error event types return a ReturnCode in the specific EventData field indicating what the error is. Possible values include:
out EventData event_data | An EventData structure is returned indicating the event and associated data. |
A value from the EventType enumeration list indicating the event type.
This method checks the event queue to determine if any events are ready for processing. If an event is ready, True is returned; otherwise, False is returned.
TRUE if an event is available.
This method returns an event handle. The application can use this handle as a file descriptor on which to select and thereby query or block on events. If the file descriptor is readable, an event is queued.
The return value is a nonzero handle number for success and 0 for failure. The handle is a file descriptor upon which selects can be issued to query or block on events.
This method turns the repeat flag on and off. If the flag is on, then the play method causes it to repeat from the beginning of the file when encountering the end of file. The playto method repeats from the current position when playto is called to the end position passed into the playto method. Repeat can take effect on the next or current play.
If repeat is set during play, a PlayComplete event is generated as each repetition is completed.
in OnOff flag | Specifies that repeat should be turned ON or OFF. |
This method returns the current setting for the repeat flag.
Returns the current setting of repeat.
This method returns the samples per second currently set. If a file is not loaded, a value of 0 is returned.
The number of samples per second in the audio track.
This method sets the time format, which specifies the units of time the object interface uses. Time parameters are specified as longs and assume the units of the current time format. Valid values are Msecs or Frames.
in TimeFormat format | A value from the TimeFormat enumeration list specifying current time units. Valid values are Msecs or Frames. |
This method returns the current setting for the time format, which defines the interpretation of Time arguments.
This method sets the speed factor for displaying video. The play and playto use the speed factor and the normal play speed to calculate the play speed. The default speed factor is 100. Speed factors are honored on a best can do basis.
This does not take affect for currently playing segments. It only applies to the next play or playto.
in unsigned long percent | Specifies a percentage by which the playback speed should be adjusted. A value of 100 specifies normal speed. |
Returns the current speed factor.
The current speed factor setting is returned as a percentage of the normal play speed.
This method returns the normal play speed, in frames per second. This normal speed is determined from the loaded file. If a file is not loaded, a value of 0 is returned.
The nominal frames per second for normal speed is returned as a long.
This method returns the current play speed, in frames per second. This speed is the normal speed scaled by the speed factor. If a file is not loaded, a value of 0 is returned.
The speed in frames per second is returned as a long.
This method steps count frames forward or backward. If the count value is negative it steps backward; otherwise, it steps forward. A value of zero does not modify the position in the file. A step count of 0 displays the current frame.
in long count | Specifies the number of frames to advance. A positive value steps forward, a negative value steps backward. |
This method freezes the current frame image on the display, but continues to play the audio if the file has an audio track. Cuepoint and position advise events continues as when playing.
InvalidState | Freeze is not a valid command for the current state. |
This method displays the movie at the maximum possible frame rate (without throwing away any frames). No audio is played. The repeat and speed factor do not apply during scan. A PlayComplete event is generated when the end of file is reached and the state transitions to pause. Since no frames are discarded apparent speed is not easily predictable and can be faster or slower than normal.
InvalidState | Scan is not a valid command for the current state. |
This method displays the movie at the maximum possible frame rate (without throwing away any frames). No audio is played. The speed factor does not apply during scan. A PlayComplete event is generated when the to location is reached and the state transitions to pause.
Usage of the to parameter, and of the state of repeat, is like that defined for playto.
in unsigned long to | Specifies the offset to scan to in units of current time format. |
OutOfRange | The to parameter is out of range. |
InvalidState | Scan is not a valid command for the current state. |
This method queries the current position of the media, and it returns the current position units of the current time format setting.
The current position in the TIME format is returned. If there is no current position (a file is not loaded) a 0 TIME is returned.
This method passes the display and window identification to the player. This window is used to display the movie. If a window has already been defined, or the player cannot connect to the specified window, an error is returned.
in string dp | A string specifying the Display window to be opened (for example, unix:0). |
in unsigned long wid | Specifies a window ID to be used for the display. |
InvalidWindow | Unable to connect to the specified display and window. |
WindowDefined | A window had already been defined. |
ColorMap | Cannot get color map. |
This method queries the display and window id for displaying the video image. If the player has no window specified, NoWindow is returned.
inout string dp | The currently set display is returned. |
inout unsigned long wid | Returns the current window id or Null if not initialized. |
This method releases a previously specified window. If the player has a window defined the player is responsible for exposure events. If the application wants to regain the window it must request its release. A release must be done before defining a new window.
This method queries the normal width and height for playback of the loaded file. NoFile is returned if the width and height are unknown (no loaded file).
inout unsigned long width | The native width of the image data is returned |
inout unsigned long height | The native height of the image data is returned |
This method queries the length of the currently loaded file. The returned value is in time format which is set by set_time_format or system default time format.
The length of the movie file in the current time units.
This method selects the audio track to play by number. A file can or cannot have multiple audio tracks. The first audio track in a movie file is 0, the second audio track is 1, etc. The default audio track is set to 0 and reset to 0 with each load. The UMSMoviePlayer supports playback of the first audio track only.
in unsigned long track_no | Specifies which audio track is selected. |
This method returns the currently selected audio track. The UMSMoviePlayer supports only the playing of the first audio track in a file, referred to as audio track 0.
The currently selected audio track number is returned.
This method returns the locations (frame number) of the I frames bounding the reference frame. It also indicates whether the reference frame itself is an I frame.
Returns TRUE if the reference frame is an I frame.
This method returns the current X color map id being used by the player. This allows the using application to install the color map as well so that the input focus on the application can result in use of the desired color map. Returns 0 if no colormap exists at this time.
The color map ID being used by the UMSMoviePlayer.
This method returns the current file format alias. A null is returned if a file is not active or the format alias cannot be determined. This is method is preferred over the get_file_format method.
out string file_format_alias | The current file format alias is returned as a string. |
The video format type string is returned. This string is the format type used by the UMSMovieFile object.
out string video_format_type | The current video format type is returned as a string. |
The audio bits per sample value is returned as a long. This is the preferred method for querying bits per sample.
inout long bits_per_sample | The number of bits per sample of audio data is returned. |
By convention 8-bit stereo data is reported as 8 bits per sample even though 2 bytes of data are required to complete a stereo sample.
The audio format type string is returned. This string is the format type used by the UMSMovieFile object.
out string audio_format_type | The current audio format type is returned as a string. |
This method is used in the presentation of device specific capabilities that are shared for all invocations of the device. An example of this is the configuration of passing through CD-ROM audio data at the device level which is mixed at the device independent of other device usage. If you enable master setting mode, you share in this configuration of the device. If you choose not to participate in the master settings, you must try to disable master_settings mode. Each device can enforce rules based on current state and as to when the master_settings mode can be entered or exited. Some devices cannot support master setting at all in which case a value of InvalidCommand is returned.
This method is used to disable the master_settings mode on the audio device in use. If the method is not supported by the audio device in use, an InvalidCommand value is returned. If the device cannot be acquired with master setting disabled, a value of Failure is returned.
This UMSMovie Player presents this method for the specific UMSAudioDevice object in use.
inout boolean enabled | A Boolean is returned indicating whether master settings are enabled or disabled for the audio device. |
The specific audio device class is returned as a string.
out string device_class | The specific audio device class in use is returned as a string. |
The specific audio device in use is returned as a string, such as /dev/acpa0.
out string device_pathname | The specific audio device in use is returned as a string. |
This UMSMovie Player presents this method for the specific UMSAudioDevice object in use.
out string exec_pathname | The pathname of the requested executable is returned as a string. |
The audio device inputs alias and outputs alias are returned. These aliases are used in the configuration file to define the input and output connections on specific audio devices.
out string inputs_alias | The audio device inputs alias is returned as a string. |
out string outputs_alias | The audio device outputs alias is returned as a string. |
The actual width and height of the image as displayed are returned as longs.
out long actual_width | The width in pixels of the displayed image. |
out long actual_height | The height in pixels of the displayed image. |
The desired width and height of the output image are set. If this is different from the native size of the image, it implies that an additional resizing step is being requested. In this case the UMSMoviePlayer first passes the request to the UMSImageWindow. If the UMSImageWindow returns Success (that is, if hardware support for resizing is available), or if the UMSImageWindow returns ValueChanged and the actual width and height are different from the original image size (that is, if the hardware is doing any form of resizing) then no further action is taken. Otherwise the requested width and height are limited to a maximum of 2 times the original width and height of the image and to a minimum of 8 pixels in each dimension, and then passed to the UMSVideoDecoder for software resizing. ValueChanged is returned if the resulting width and height are not the same as the requested width and height.
For introductory information, see Media Handler Objects.