Skip to content

Commit

Permalink
Remove IVideo and IVideoHandler (dotnet#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbritch authored Aug 25, 2022
1 parent 0404227 commit 579d301
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 86 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace VideoDemos.Controls
{
public class Video : View, IVideo, IVideoController
public class Video : View, IVideoController
{
#region Bindable Properties

Expand Down Expand Up @@ -115,27 +115,27 @@ public void Play()
{
VideoPositionEventArgs args = new VideoPositionEventArgs(Position);
PlayRequested?.Invoke(this, args);
Handler?.Invoke(nameof(IVideo.PlayRequested), args);
Handler?.Invoke(nameof(Video.PlayRequested), args);
}

public void Pause()
{
VideoPositionEventArgs args = new VideoPositionEventArgs(Position);
PauseRequested?.Invoke(this, args);
Handler?.Invoke(nameof(IVideo.PauseRequested), args);
Handler?.Invoke(nameof(Video.PauseRequested), args);
}

public void Stop()
{
VideoPositionEventArgs args = new VideoPositionEventArgs(Position);
StopRequested?.Invoke(this, args);
Handler?.Invoke(nameof(IVideo.StopRequested), args);
Handler?.Invoke(nameof(Video.StopRequested), args);
}

void OnTimerTick(object sender, EventArgs e)
{
UpdateStatus?.Invoke(this, EventArgs.Empty);
Handler?.Invoke(nameof(IVideo.UpdateStatus));
Handler?.Invoke(nameof(Video.UpdateStatus));
}

void SetTimeToEnd()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace VideoDemos.Handlers
{
public partial class VideoHandler : ViewHandler<IVideo, MauiVideoPlayer>
public partial class VideoHandler : ViewHandler<Video, MauiVideoPlayer>
{
protected override MauiVideoPlayer CreatePlatformView() => new MauiVideoPlayer(Context, VirtualView);

Expand All @@ -22,27 +22,27 @@ protected override void DisconnectHandler(MauiVideoPlayer platformView)
base.DisconnectHandler(platformView);
}

public static void MapAreTransportControlsEnabled(IVideoHandler handler, IVideo video)
public static void MapAreTransportControlsEnabled(VideoHandler handler, Video video)
{
handler.PlatformView?.UpdateTransportControlsEnabled();
}

public static void MapSource(IVideoHandler handler, IVideo video)
public static void MapSource(VideoHandler handler, Video video)
{
handler.PlatformView?.UpdateSource();
}

public static void MapPosition(IVideoHandler handler, IVideo video)
public static void MapPosition(VideoHandler handler, Video video)
{
handler.PlatformView?.UpdatePosition();
}

public static void MapUpdateStatus(IVideoHandler handler, IVideo video, object? args)
public static void MapUpdateStatus(VideoHandler handler, Video video, object? args)
{
handler.PlatformView?.UpdateStatus();
}

public static void MapPlayRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapPlayRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand All @@ -51,7 +51,7 @@ public static void MapPlayRequested(IVideoHandler handler, IVideo video, object?
handler.PlatformView?.PlayRequested(position);
}

public static void MapPauseRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapPauseRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand All @@ -60,7 +60,7 @@ public static void MapPauseRequested(IVideoHandler handler, IVideo video, object
handler.PlatformView?.PauseRequested(position);
}

public static void MapStopRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapStopRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

namespace VideoDemos.Handlers
{
public partial class VideoHandler : ViewHandler<IVideo, FrameworkElement>
public partial class VideoHandler : ViewHandler<Video, FrameworkElement>
{
protected override FrameworkElement CreatePlatformView() => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapAreTransportControlsEnabled(IVideoHandler handler, IVideo video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapSource(IVideoHandler handler, IVideo video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPosition(IVideoHandler handler, IVideo video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapUpdateStatus(IVideoHandler handler, IVideo video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPlayRequested(IVideoHandler handler, IVideo video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPauseRequested(IVideoHandler handler, IVideo video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapStopRequested(IVideoHandler handler, IVideo video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapAreTransportControlsEnabled(VideoHandler handler, Video video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapSource(VideoHandler handler, Video video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPosition(VideoHandler handler, Video video) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapUpdateStatus(VideoHandler handler, Video video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPlayRequested(VideoHandler handler, Video video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapPauseRequested(VideoHandler handler, Video video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
public static void MapStopRequested(VideoHandler handler, Video video, object? arg) => throw new PlatformNotSupportedException("No MediaElement control on Windows.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@

namespace VideoDemos.Handlers
{
public partial class VideoHandler : IVideoHandler
public partial class VideoHandler
{
public static IPropertyMapper<IVideo, IVideoHandler> PropertyMapper = new PropertyMapper<IVideo, IVideoHandler>(ViewHandler.ViewMapper)
public static IPropertyMapper<Video, VideoHandler> PropertyMapper = new PropertyMapper<Video, VideoHandler>(ViewHandler.ViewMapper)
{
[nameof(IVideo.AreTransportControlsEnabled)] = MapAreTransportControlsEnabled,
[nameof(IVideo.Source)] = MapSource,
[nameof(IVideo.Position)] = MapPosition
[nameof(Video.AreTransportControlsEnabled)] = MapAreTransportControlsEnabled,
[nameof(Video.Source)] = MapSource,
[nameof(Video.Position)] = MapPosition
};

public static CommandMapper<IVideo, IVideoHandler> CommandMapper = new(ViewCommandMapper)
public static CommandMapper<Video, VideoHandler> CommandMapper = new(ViewCommandMapper)
{
[nameof(IVideo.UpdateStatus)] = MapUpdateStatus,
[nameof(IVideo.PlayRequested)] = MapPlayRequested,
[nameof(IVideo.PauseRequested)] = MapPauseRequested,
[nameof(IVideo.StopRequested)] = MapStopRequested
[nameof(Video.UpdateStatus)] = MapUpdateStatus,
[nameof(Video.PlayRequested)] = MapPlayRequested,
[nameof(Video.PauseRequested)] = MapPauseRequested,
[nameof(Video.StopRequested)] = MapStopRequested
};

IVideo IVideoHandler.VirtualView => VirtualView;

PlatformView IVideoHandler.PlatformView => PlatformView;

public VideoHandler() : base(PropertyMapper, CommandMapper)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace VideoDemos.Handlers
{
public partial class VideoHandler : ViewHandler<IVideo, MauiVideoPlayer>
public partial class VideoHandler : ViewHandler<Video, MauiVideoPlayer>
{
protected override MauiVideoPlayer CreatePlatformView() => new MauiVideoPlayer(VirtualView);

Expand All @@ -22,27 +22,27 @@ protected override void DisconnectHandler(MauiVideoPlayer platformView)
base.DisconnectHandler(platformView);
}

public static void MapAreTransportControlsEnabled(IVideoHandler handler, IVideo video)
public static void MapAreTransportControlsEnabled(VideoHandler handler, Video video)
{
handler?.PlatformView.UpdateTransportControlsEnabled();
}

public static void MapSource(IVideoHandler handler, IVideo video)
public static void MapSource(VideoHandler handler, Video video)
{
handler?.PlatformView.UpdateSource();
}

public static void MapPosition(IVideoHandler handler, IVideo video)
public static void MapPosition(VideoHandler handler, Video video)
{
handler?.PlatformView.UpdatePosition();
}

public static void MapUpdateStatus(IVideoHandler handler, IVideo video, object? args)
public static void MapUpdateStatus(VideoHandler handler, Video video, object? args)
{
handler.PlatformView?.UpdateStatus();
}

public static void MapPlayRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapPlayRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand All @@ -51,7 +51,7 @@ public static void MapPlayRequested(IVideoHandler handler, IVideo video, object?
handler.PlatformView?.PlayRequested(position);
}

public static void MapPauseRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapPauseRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand All @@ -60,7 +60,7 @@ public static void MapPauseRequested(IVideoHandler handler, IVideo video, object
handler.PlatformView?.PauseRequested(position);
}

public static void MapStopRequested(IVideoHandler handler, IVideo video, object? args)
public static void MapStopRequested(VideoHandler handler, Video video, object? args)
{
if (args is not VideoPositionEventArgs)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class MauiVideoPlayer : CoordinatorLayout
MediaController _mediaController;
bool _isPrepared;
Context _context;
IVideo _video;
Video _video;

public MauiVideoPlayer(Context context, IVideo video) : base(context)
public MauiVideoPlayer(Context context, Video video) : base(context)
{
_context = context;
_video = video;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class MauiVideoPlayer : UIView
AVPlayer _player;
AVPlayerItem _playerItem;
AVPlayerViewController _playerViewController;
IVideo _video;
Video _video;

public MauiVideoPlayer(IVideo video)
public MauiVideoPlayer(Video video)
{
_video = video;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class MauiVideoPlayer : UIView
AVPlayer _player;
AVPlayerItem _playerItem;
AVPlayerViewController _playerViewController;
IVideo _video;
Video _video;

public MauiVideoPlayer(IVideo video)
public MauiVideoPlayer(Video video)
{
_video = video;

Expand Down

0 comments on commit 579d301

Please sign in to comment.