MoviePlayer

From Xojo Documentation

Revision as of 16:26, 15 November 2020 by Gperlman (talk | contribs)

Class (inherits from RectControl)

Displays a control for playing movies.

Events
Close DragOver MouseMove
ConstructContextualMenu DropObject MouseWheel
ContextualMenuAction KeyDown Open
ControllerSizeChanged KeyUp Play
DragEnter MouseEnter Stop
DragExit MouseExit
Properties
Active fa-lock-32.png Height PlayerType
AllowAutoDeactivate Index fa-lock-32.png Position
AllowTabStop Left RepeatInReverse
AutoAdjustToMovieSize LockBottom Scope fa-lock-32.png
AutoPlay LockLeft TabIndex
AutoRepeat LockRight Tooltip
Border fa-lock-32.png LockTop Top
ControllerHeight fa-lock-32.png MouseCursor Transparent
ControllerWidth fa-lock-32.png MouseX fa-lock-32.png TrueWindow fa-lock-32.png
Duration fa-lock-32.png MouseY fa-lock-32.png Visible
Enabled Movie Volume
Handle fa-lock-32.png Name fa-lock-32.png Width
HasController OLEMovieObject fa-lock-32.png Window fa-lock-32.png
HasStepControls PanelIndex
HasVolumeControl Parent
Methods
AcceptFileDrop Close Refresh
AcceptPictureDrop DrawInto SetFocus
AcceptRawDataDrop Invalidate Stop
AcceptTextDrop Play

Notes

Windows uses the Windows Movie Player to play movies and macOS uses AVFoundation. On Linux, the MoviePlayer uses GStreamer by default (it requires version 0,10+) and uses Xine if GStreamer is not available.

The HasController property dictates if the movie controls (if any) will be displayed. Passing False means that there will be no user controls available. Passing True means that the regular movie controls will be available.

Because movie loading is asynchronous, you should not have AutoAdjustToMovieSize = True if you are also manually modifying the Width and Height as it is possible that the auto resizing will occur after you have changed the size.

Windows Resizing

Movies do not automatically resize to fill the screen on Windows. You can alter this behavior with this code:

Var obj As OLEObject = MoviePlayer1.MovieController
obj.Value("stretchToFit") = True

Sample Code

This code sets the movie "myHomeMovie" as the movie to be played.

MoviePlayer1.Movie = myHomeMovie

This code loads a movie called "MyMovie" from the current folder into MoviePlayer1 and plays it.

Var f As FolderItem
f = FolderItem.ShowOpenFileDialog("MyMovie")
MoviePlayer1.HasVolumeControl = True
MoviePlayer1.HasStepControls = False
MoviePlayer1.Movie = Movie.Open(f)
MoviePlayer1.Play

If you added the movie to your project, you can assign it to the movie property with only one line of code:

MoviePlayer1.Movie = MyMovie

The following code uses the MovieController property to get the current position of the player:

Var pos As Double
pos = MoviePlayer1.MovieController.Controls.CurrentPosition

See Also

Movie.OpenURL function; Movie, WebMoviePlayer classes.