MediaPlayer as a background service
I need to implement something similar to the PulseMusic sample https://github.com/mfkl/libvlcsharp-samples/tree/e052357c9715a5f1bb937aef67764ab5aaba4544/PulseMusic but for videos.
Is it possible to reuse MediaPlayer between video views? I need to have MediaPlayer working in the service so when I switch between the screens or after pause/resume (Android) to not initializes the player again.
Below you can find the sample from my code.
public class RtspVideoView : VideoView
public void Play(){
MediaPlauer = MediaService.Player
}
}
public MediaService{
public void Start()
{
Core.Initialize();
_libVLC = new LibVLC(_streamOptions);
_mediaPlayer = new MediaPlayer(_libVLC)
{
EnableHardwareDecoding = false
};
_mediaPlayer.SetVideoFormat(VideoFormat, Width, Height, _pitch);
_mediaPlayer.SetVideoCallbacks(Lock, null, Display);
var media = new Media(_libVLC, StreamUrl, FromType.FromLocation);
var config = new MediaConfiguration();
media.AddOption(config);
foreach (var option in _mediaOptions)
{
media.AddOption(option);
}
_mediaPlayer.Play(media);
}
}