Commit a76059ef authored by Martin Finkel's avatar Martin Finkel
Browse files

comments

parent 4d687a54
...@@ -22,12 +22,14 @@ namespace PulseMusic ...@@ -22,12 +22,14 @@ namespace PulseMusic
} }
public void Init() public void Init()
{ {
// create a libvlc media
_mp.Media = new Media(_libVLC, "https://archive.org/download/ImagineDragons_201410/imagine%20dragons.mp4", Media.FromType.FromLocation); _mp.Media = new Media(_libVLC, "https://archive.org/download/ImagineDragons_201410/imagine%20dragons.mp4", Media.FromType.FromLocation);
// disable video output // disable video output, we only need audio
_mp.Media.AddOption(":no-video"); _mp.Media.AddOption(":no-video");
// subscribe to libvlc playback events
_mp.TimeChanged += TimeChanged; _mp.TimeChanged += TimeChanged;
_mp.PositionChanged += PositionChanged; _mp.PositionChanged += PositionChanged;
_mp.LengthChanged += LengthChanged; _mp.LengthChanged += LengthChanged;
...@@ -35,6 +37,8 @@ namespace PulseMusic ...@@ -35,6 +37,8 @@ namespace PulseMusic
_mp.Playing += Playing; _mp.Playing += Playing;
_mp.Paused += Paused; _mp.Paused += Paused;
// subscribe to UI app events for seeking.
MessagingCenter.Subscribe<string>(MessengerKeys.App, MessengerKeys.Rewind, vm => MessagingCenter.Subscribe<string>(MessengerKeys.App, MessengerKeys.Rewind, vm =>
{ {
Debug.WriteLine("Rewind"); Debug.WriteLine("Rewind");
...@@ -56,6 +60,8 @@ namespace PulseMusic ...@@ -56,6 +60,8 @@ namespace PulseMusic
else _mp.Pause(); else _mp.Pause();
} }
// when the libvlc mediaplayer events fire, publish an event with the MessagingCenter
private void PositionChanged(object sender, MediaPlayerPositionChangedEventArgs e) => private void PositionChanged(object sender, MediaPlayerPositionChangedEventArgs e) =>
MessagingCenter.Send(MessengerKeys.App, MessengerKeys.Position, e.Position); MessagingCenter.Send(MessengerKeys.App, MessengerKeys.Position, e.Position);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment