MediaPlayer

Qualified name: delphifmx.MediaPlayer

class MediaPlayer

Bases: FmxObject

Nonvisual component for media file playback. Use a TMediaPlayer component for easy access to media files. The currently accessed media file is specified through the Media property. To specify the media file to be played by the current TMediaPlayer, set the FileName property. The file name must include the path of the file, so it can be localized on the memory, and the extension. Call the Play and Stop methods to start playing a media file, or to stop or pause a running media file. The current position is specified through the CurrentTime property. TMediaPlayer also exposes media file properties such as Duration, VideoSize, Volume or State. TMediaPlayer can play back audio files and the audio component of a video file. To display a video file, use a TMediaPlayerControl component. For more information, see Audio-Video in FireMonkey.

Note: In order to play an audio file using TMediaPlayer, use the appropriate format: .wav on Windows .caf on iOS and OS X .3GP on Android

Methods

Clear

Clears the current media player.

Play

Starts playing the current Media.

Stop

Stops or pauses playing the current Media.

Attributes

ActionClient

Specifies whether the component object has an associated action.

Children

Stores an array of children attached to this parent component.

ChildrenCount

Read-only property that specifies the number of children in the children list.

ClassName

Returns the TObject.ClassName

ComObject

Specifies the interface reference implemented by the component.

ComponentCount

Returns the owned component count

ComponentIndex

Indicates the position of the component in its owner's Components property array.

ComponentState

Describes the current state of the component, indicating when a component needs to avoid certain actions.

ComponentStyle

Governs the behavior of the component.

Components

Returns an iterator over the owned components

CurrentTime

Specifies the current playback position.

Data

Stores a Tvalue, which is a data structure that can store different kinds of data types.

DesignInfo

Contains information used by the Form designer.

Duration

Specifies the total play time of the current media file attached to the media player.

FileName

Specifies the media file name played by the current media player.

Index

Specifies the index of the child object in the children array attached to this object.

Media

Specifies the current TMedia attached to this media player.

Name

Specifies the name of the component as referenced in code.

Observers

Indicates the TObservers object added to the TComponent.

Owner

Returns the Component Owner

Parent

Returns/Sets the Control Visibility

Root

Specifies the root parent of this object.

State

Specifies whether the current attached Media is playing or is stopped.

Stored

Specifies whether this object is stored in the .XFM file.

StyleName

Specifies the style name for this FMX component.

Tag

Stores a NativeInt integral value as a part of a component.

TagFloat

Custom property that stores any floating-point value.

TagObject

Custom property that stores any object value.

TagString

Custom property that stores any string value.

VCLComObject

Represents information used internally by components that support COM.

VideoSize

Specifies the resolution of the current video file.

Volume

Specifies the audio volume of the current media file.

Clear()

Clears the current media player. Call Clear to clear the current Media attached to the media player. Clear also empties the FileName property.

CurrentTime

Specifies the current playback position. CurrentTime is measured in 100ns. To obtain s, divide CurrentTime by MediaTimeScale. Set CurrentTime to control the current position to be played.

Type:

int

Duration

Specifies the total play time of the current media file attached to the media player. Duration is measured in 100ns. To obtain s, divide Duration by MediaTimeScale.

Type:

int

FileName

Specifies the media file name played by the current media player. Media is assigned and created when the FileName property is set. The file name must include the path of the file, so it can be localized on the memory, and the extension. To empty the current Media attached to the media player, call the Clear method.

Type:

str

Media

Specifies the current TMedia attached to this media player. Call the Play and Stop methods to start playing, or to stop or pause the current Media file, respectively. Media is assigned and created when the FileName property is set. TMediaPlayer exposes the Media properties through the following properties: Duration, VideoSize, CurrentTime, Volume, and State. To empty the current Media attached to the media player, call the Clear method. If Media type is audio, then calling Play will start playing the audio file. If Media type is video, then calling Play will just play the audio component of the specified video file. To display a video file, use a TMediaPlayerControl, and link the current TMediaPlayer to it by setting the MediaPlayer property of the TMediaPlayerControl.

Type:

Media

Parent

Returns/Sets the Control Visibility

Play()

Starts playing the current Media. Call the Play method to play the current Media. If Media is not assigned, Play does nothing. To stop or pause the current media file from playing, call the Stop method.

State

Specifies whether the current attached Media is playing or is stopped. If the current media file is not assigned or supported, then State is set to Unavailable. If the current media file is playing, then State is set to Playing, otherwise it is set to Stopped.

Type:

MediaState

Stop()

Stops or pauses playing the current Media. Call Stop to stop or to pause the current Media. If Media is not assigned, Stop does nothing. To start playing the current media file, call the Play method.

VideoSize

Specifies the resolution of the current video file. VideoSize specifies the native width and height of the current media file, in pixels. VideoSize is a TPointF. The X coordinate of the point represents the width of the window, and the Y coordinate of the point represents the height of the window. If the media file is audio only and does not have a window to be displayed, or if no media file is attached to the media player, then VideoSize is (0,0).

Type:

PointF

Volume

Specifies the audio volume of the current media file. Volume takes values in the range from 0 through 1. If Volume is 1, then the media file is played at the maximum native volume. If Volume is 0, then the media file is mute. If there is no media file attached to the current media player, then Volume is 1.

Type:

float