mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using Azaion.Common.Services;
|
||||
using LibVLCSharp.Shared;
|
||||
|
||||
namespace Azaion.Suite.Services;
|
||||
|
||||
public class VlcMediaPlayerService : IMediaPlayerService
|
||||
{
|
||||
private readonly MediaPlayer _mediaPlayer;
|
||||
private readonly LibVLC _libVlc;
|
||||
|
||||
public VlcMediaPlayerService(MediaPlayer mediaPlayer, LibVLC libVlc)
|
||||
{
|
||||
_mediaPlayer = mediaPlayer;
|
||||
_libVlc = libVlc;
|
||||
|
||||
_mediaPlayer.Playing += (s, e) => Playing?.Invoke(s, e);
|
||||
_mediaPlayer.Paused += (s, e) => Paused?.Invoke(s, e);
|
||||
_mediaPlayer.Stopped += (s, e) => Stopped?.Invoke(s, e);
|
||||
_mediaPlayer.PositionChanged += (s, e) => PositionChanged?.Invoke(s, e);
|
||||
_mediaPlayer.LengthChanged += (s, e) => LengthChanged?.Invoke(s, e);
|
||||
}
|
||||
|
||||
public void Play() => _mediaPlayer.Play();
|
||||
public void Pause() => _mediaPlayer.Pause();
|
||||
public void Stop() => _mediaPlayer.Stop();
|
||||
|
||||
public long Time
|
||||
{
|
||||
get => _mediaPlayer.Time;
|
||||
set => _mediaPlayer.Time = value;
|
||||
}
|
||||
|
||||
public float Position
|
||||
{
|
||||
get => _mediaPlayer.Position;
|
||||
set => _mediaPlayer.Position = value;
|
||||
}
|
||||
|
||||
public int Volume
|
||||
{
|
||||
get => _mediaPlayer.Volume;
|
||||
set => _mediaPlayer.Volume = value;
|
||||
}
|
||||
|
||||
public bool IsPlaying => _mediaPlayer.IsPlaying;
|
||||
public long Length => _mediaPlayer.Length;
|
||||
|
||||
public void SetMedia(string mediaPath)
|
||||
{
|
||||
using var media = new Media(_libVlc, mediaPath);
|
||||
_mediaPlayer.Media = media;
|
||||
}
|
||||
|
||||
public void TakeSnapshot(uint num, string path, uint width, uint height)
|
||||
{
|
||||
_mediaPlayer.TakeSnapshot(num, path, width, height);
|
||||
}
|
||||
|
||||
public event EventHandler? Playing;
|
||||
public event EventHandler? Paused;
|
||||
public event EventHandler? Stopped;
|
||||
public event EventHandler? PositionChanged;
|
||||
public event EventHandler? LengthChanged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user