Sign in Join
Wiki copytemporary

TMPlayerControl: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Introduction
22
33TMPlayerControl is a LCL control that embeds "mplayer" - a movie player available on several platforms. TMPlayerControl only works under X/gtk2 and Windows. TMPlayerControl can be used to play any mplayer supported video or audio file.
44
55### Authors
66
77Mattias Gaertner (package maintainer)\
88Michael Koecher (contributor)\
99Mike Thompson (contributor)
1010
1111### License
1212
1313[Modified](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.modifiedLGPL.txt) [LGPL](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.LGPL.txt) (same as FPC RTL and Lazarus LCL).
1414
1515### Download
1616
1717The latest stable release can be found at svn:
1818
1919 svn checkout svn://svn.code.sf.net/p/lazarus-ccr/svn/components/mplayer mplayer
2020
2121mplayer, and additional codecs, can be downloaded from <http://www.mplayerhq.hu/>. The additional codecs must be installed separately, but are not necessary for many common formats.
2222
2323## Distributing mplayer
2424
2525> **Warning:** mplayer can be easily bundled with your application installation. However mplayer uses FFmpeg and the legal licensing warning at <http://www.ffmpeg.org/legal.html> could also apply (see last question under Mini-Patent FAQ).\
2626> It is recommended that the end-user install mplayer on their system instead of it being distributed with your application.
2727
2828## Usage
2929
3030The control can be dropped on any form, and incorporates the video playback area.\
3131Additional controls such as Trackbars for progess/volume and buttons for playback control need to be added manually, with their values being set during the appropriate events.
3232
3333mplayer must be available on the end user system. Either installed with the mplayer folder being in the PATH environment variable, or with the MPlayerPath property pointing to the mplayer executable.
3434
3535TMPlayerControl only implements a very small set of mplayer features: **Play**, **Stop**, **Pause**, **Loop**, **Volume**, **Duration**, **Position** and **GrabImage**, essentially focusing on anything required for multimedia playback.
3636
3737TMPlayerControl sets a minor selection of mplayer properties at run time. Additional parameters can be set via **StartParam**.\
3838See <http://mplayerhq.hu/DOCS/man/en/mplayer.1.html#GENERAL%20OPTIONS> for a full list of available parameters.
3939
4040TMPlayerControl controls mplayer in slave mode. Slave commands can be sent directly to mplayer after multimedia is loaded (i.e. after calling Play) by using **SendMPlayerCommand(Cmd: string);**\
4141**SendMPlayerCommand** is not needed for simple video playback, and is made available for advanced mplayer features.\
4242For a full list of available slave comamnds visit <http://www.mplayerhq.hu/DOCS/tech/slave.txt> or enter the following at the command prompt.
4343
4444``` bash
4545mplayer -input cmdlist
4646```
4747
4848### Example
4949
5050In the examples folder, see FullFeatured\mplayerTestHarness.lpr for a full demonstration of TMPlayerControl capabilities, as well as additional functionality for querying mplayer for available commands.
5151
52-<img src="FullFeaturedDemo.jpg" title="FullFeatured example program" width="400" />
52+![](/wiki-images/8/8b/FullFeaturedDemo.jpg)
5353
5454### Methods
5555
5656The following Methods and Properties are available:
5757
5858| Method | Description |
5959|----|----|
6060| function FindMPlayerPath : Boolean; | TMPlayerControl searches for mplayer in the PATH or in a subfolder of the application folder called "mplayer". If found, then sets MPlayerPath and returns True |
6161| property MPlayerPath: string; | R/W. Full path to the mplayer executable. Either populated by FindMPlayerPath, or programmatically |
6262| property StartParam: string; | R/W. Any additional parameters to be sent to mplayer before the multimedia file is initialised. See <http://mplayerhq.hu/DOCS/man/en/mplayer.1.html#GENERAL%20OPTIONS> for a full set of available parameters |
6363| property Filename: string; | R/W. The multimedia file to be played |
6464| procedure Play; | All the above must be configured correct before this command is called. This initialises mplayer, putting it into slave mode with the file loaded. mplayer will automatically start playing the file. |
6565| procedure Stop; | This stops the video file playing, which in turn stops mplayer. After this is called, many of the properties will no longer be available. |
6666| property Loop: integer; | R/W. This instructs mplayer to loop the video. -1 no, 0 forever, 1 once, 2 twice, ... |
6767| property Paused: boolean; | R/W. Either set or retrieve the paused state. |
6868| function Running: boolean; | R/O. Is mplayer running? |
6969| function Playing: boolean; | R/O. Is mplaying running with a file loaded? There is only a small window in time between the file stopping and mplayer itself stopping running. |
7070| property ImagePath: string; | R/W. The folder you want captured image grabs to be saved in. |
7171| procedure GrabImage; | Instruct mplayer to grab an image. In testing, success of this call is dependent upon a combination of the codec mplayer is using, and the renderer being used. Under windows, optimal results were returned with the direct3d renderer (-vo direct3d) |
7272| property LastImageFilename: String; | R/O. The filename of the last image grabbed. The filename of the last image grabbed is also passed as a parameter to the OnGrabImage event. |
7373| property Volume: integer; | R/W. 0 = mute. 100 = max |
7474| property Rate: single; | R/W. Playback rate. 1 = normal speed. mplayer allows values between 0.1 and 100 (i.e. no reverse) |
7575| property Duration: single; | R/O. The length of the loaded video file in seconds. |
7676| property Position: single; | R/W. Used to set or retrieve the current position of the video file in seconds. Current video position is queried every half second, so during playback at normal speed, there is only a half second accuracy. |
7777| property VideoInfo: TVideoInfo; | R/O. Only populated after OnPlay event. Record containing Codec, bitrate, width, height etc |
7878| property AudioInfo: TAudioInfo; | R/O. Only populated after OnPlay event. Record containing Codec, SampleRate, Bitrate etc. |
7979| procedure SendMPlayerCommand(Cmd: string); | Additional commands can be sent directly to mplayer, and the results can be queried with the OnFeedback event. See <http://www.mplayerhq.hu/DOCS/tech/slave.txt> for a full list of available commands |
8080
8181### Events
8282
8383The following events are available:
8484
8585| Event | Description |
8686|----|----|
8787| OnPlay | This event is broadcast immediately after mplayer finishes initialising the file to be played. At the point this event is launched the VideoInfo and AudioInfo records will be populated |
8888| OnPlaying | This event is broadcast regularly while the multimedia file is playing. You can use this event to keep a TTrackbar synchronised with the playback |
8989| OnStop | This event is broadcast when the multimedia file stops. As soon as this event is launched the VideoInfo and AudioInfo records are cleared |
9090| OnFeedback | mplayer is polled frequently by TMPlayerControl. Most text output on the standard console will be available through the TStringList parameter. Some housekeeping information (such as the frequent requests for video position) are removed from this TStringList parameter. |
9191| OnError | mplayer is polled frequently by TMPlayerControl. All text output on the error console will be available through the TStringList parameter. |
9292| OnGrabImage | This event is raised following an GrabImage request. If successfull, then the filename to the image is returned. |
9393| OnClick, OnMouseUp, OnMouseDown, OnMouseWheel | Standard LCL events. OnMouseWheel can be used to allow the video to scroll through the video. An example of this is provided in the FullFeatured demo. |
9494
9595## See also
9696
9797[[Video Playback Libraries]]
9898
9999---
100100*From the Free Pascal wiki, page "TMPlayerControl", as it stood on 2019-12-28 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
101101Category: Lazarus-CCR
102102Category: Multimedia
103103Category: Video

Back to history