MoviePlayer

From Xojo Documentation

Class (inherits from RectControl)

Displays a control for playing movies.

Events
ControllerSizeChanged MovieStarted MovieStopped


Properties
AutoAdjustToMovieSize Duration fa-lock-32.png PlayerType
AutoPlay HasController Position
AutoRepeat HasStepControls RepeatInReverse
Border fa-lock-32.png HasVolumeControl Volume
ControllerHeight fa-lock-32.png Movie
ControllerWidth fa-lock-32.png OLEMovieObject fa-lock-32.png


Methods
Play Stop

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.