MediaPlayer methods
MediaPlayer has a number of methods for controlling player parameters:
- Play() starts playback of a media file;
- Pause() pauses playback;
- SetCurrentTime(seconds float64) sets the current playback time in seconds;
- CurrentTime() float64 returns the current playing time in seconds;
- Duration() float64 returns the duration of the media file in seconds;
- SetPlaybackRate(rate float64) sets the playback speed. Normal speed is 1.0;
- PlaybackRate() float64 returns the current playback speed;
- SetVolume(volume float64) sets the volume speed in the range from 0 (silence) to 1 (maximum volume);
- Volume() float64 returns the current volume;
- IsEnded() bool returns true if the end of the media file is reached;
- IsPaused() bool returns true if playback is paused.
For quick access to these methods, there are global functions:
func MediaPlayerPlay(view View, playerID string) func MediaPlayerPause(view View, playerID string) func SetMediaPlayerCurrentTime(view View, playerID string, seconds float64) func MediaPlayerCurrentTime(view View, playerID string) float64 func MediaPlayerDuration(view View, playerID string) float64 func SetMediaPlayerVolume(view View, playerID string, volume float64) func MediaPlayerVolume(view View, playerID string) float64 func SetMediaPlayerPlaybackRate(view View, playerID string, rate float64) func MediaPlayerPlaybackRate(view View, playerID string) float64 func IsMediaPlayerEnded(view View, playerID string) bool func IsMediaPlayerPaused(view View, playerID string) bool
where view is the root View, playerID is the id of AudioPlayer or VideoPlayer