diff --git a/MediaManager.UWP.Tests/Plugin.MediaManager.UWP.Tests.csproj b/MediaManager.UWP.Tests/Plugin.MediaManager.UWP.Tests.csproj
index a305bac0..0f52228c 100644
--- a/MediaManager.UWP.Tests/Plugin.MediaManager.UWP.Tests.csproj
+++ b/MediaManager.UWP.Tests/Plugin.MediaManager.UWP.Tests.csproj
@@ -100,6 +100,7 @@
UnitTestApp.xaml
+
diff --git a/MediaManager.UWP.Tests/Unit/MediaButtonPlaybackControllerTest.cs b/MediaManager.UWP.Tests/Unit/MediaButtonPlaybackControllerTest.cs
index 5f482b2a..ec28fd5b 100644
--- a/MediaManager.UWP.Tests/Unit/MediaButtonPlaybackControllerTest.cs
+++ b/MediaManager.UWP.Tests/Unit/MediaButtonPlaybackControllerTest.cs
@@ -14,7 +14,7 @@ public void ctor_MediaButtonsAreEnabled()
{
var controlsMock = new Mock();
- new MediaButtonPlaybackController(controlsMock.Object, new Mock().Object);
+ new MediaButtonPlaybackController(controlsMock.Object, new PlaybackControllerProviderMock().Object);
controlsMock.VerifySet(m => m.IsNextEnabled = true);
controlsMock.VerifySet(m => m.IsPreviousEnabled = true);
@@ -28,7 +28,7 @@ public void SubscribeToNotifications_SubscribeToMediaButtonEventsIsCalled()
{
var controlsMock = new Mock();
- var controller = new MediaButtonPlaybackController(controlsMock.Object, new Mock().Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, new PlaybackControllerProviderMock().Object);
controller.SubscribeToNotifications();
controlsMock.Verify(m => m.SubscribeToMediaButtonEvents());
@@ -39,7 +39,7 @@ public void UnsubscribeFromNotifications_CallsUnsubscribeFromMediaButtonEvents()
{
var controlsMock = new Mock();
- var controller = new MediaButtonPlaybackController(controlsMock.Object, new Mock().Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, new PlaybackControllerProviderMock().Object);
controller.UnsubscribeFromNotifications();
controlsMock.Verify(m => m.UnsubscribeFromMediaButtonEvents());
@@ -50,8 +50,9 @@ public void NextButtonPressed_PlayNextIsCalled()
{
var controlsMock = new Mock();
var playbackControllerMock = new Mock();
+ var playbackControllerProviderMock = new PlaybackControllerProviderMock().SetupGetPlayBackController(playbackControllerMock.Object);
- var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerMock.Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerProviderMock.Object);
controller.SubscribeToNotifications();
var args = new Mock();
@@ -66,8 +67,9 @@ public void PreviousButtonPressed_PlayPreviousOrSeekToStartIsCalled()
{
var controlsMock = new Mock();
var playbackControllerMock = new Mock();
+ var playbackControllerProviderMock = new PlaybackControllerProviderMock().SetupGetPlayBackController(playbackControllerMock.Object);
- var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerMock.Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerProviderMock.Object);
controller.SubscribeToNotifications();
var args = new Mock();
@@ -82,8 +84,9 @@ public void PlayButtonPressed_PlayIsCalled()
{
var controlsMock = new Mock();
var playbackControllerMock = new Mock();
+ var playbackControllerProviderMock = new PlaybackControllerProviderMock().SetupGetPlayBackController(playbackControllerMock.Object);
- var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerMock.Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerProviderMock.Object);
controller.SubscribeToNotifications();
var args = new Mock();
@@ -98,8 +101,9 @@ public void PauseButtonPressed_PauseIsCalled()
{
var controlsMock = new Mock();
var playbackControllerMock = new Mock();
+ var playbackControllerProviderMock = new PlaybackControllerProviderMock().SetupGetPlayBackController(playbackControllerMock.Object);
- var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerMock.Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerProviderMock.Object);
controller.SubscribeToNotifications();
var args = new Mock();
@@ -114,8 +118,9 @@ public void StopButtonPressed_StopIsCalled()
{
var controlsMock = new Mock();
var playbackControllerMock = new Mock();
+ var playbackControllerProviderMock = new PlaybackControllerProviderMock().SetupGetPlayBackController(playbackControllerMock.Object);
- var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerMock.Object);
+ var controller = new MediaButtonPlaybackController(controlsMock.Object, playbackControllerProviderMock.Object);
controller.SubscribeToNotifications();
var args = new Mock();
diff --git a/MediaManager.UWP.Tests/Unit/PlaybackControllerProviderMock.cs b/MediaManager.UWP.Tests/Unit/PlaybackControllerProviderMock.cs
new file mode 100644
index 00000000..6eb20ba8
--- /dev/null
+++ b/MediaManager.UWP.Tests/Unit/PlaybackControllerProviderMock.cs
@@ -0,0 +1,14 @@
+using Moq;
+using Plugin.MediaManager.Abstractions;
+
+namespace Plugin.MediaManager.UWP.Tests.Unit
+{
+ internal class PlaybackControllerProviderMock : Mock
+ {
+ public PlaybackControllerProviderMock SetupGetPlayBackController(IPlaybackController playbackController)
+ {
+ Setup(mock => mock.PlaybackController).Returns(playbackController);
+ return this;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MediaManager.UWP/IPlaybackControllerProvider.cs b/MediaManager.UWP/IPlaybackControllerProvider.cs
new file mode 100644
index 00000000..28f47ce4
--- /dev/null
+++ b/MediaManager.UWP/IPlaybackControllerProvider.cs
@@ -0,0 +1,9 @@
+using Plugin.MediaManager.Abstractions;
+
+namespace Plugin.MediaManager
+{
+ internal interface IPlaybackControllerProvider
+ {
+ IPlaybackController PlaybackController { get; }
+ }
+}
\ No newline at end of file
diff --git a/MediaManager.UWP/MediaButtonPlaybackController.cs b/MediaManager.UWP/MediaButtonPlaybackController.cs
index 0b8649e6..f393fb48 100644
--- a/MediaManager.UWP/MediaButtonPlaybackController.cs
+++ b/MediaManager.UWP/MediaButtonPlaybackController.cs
@@ -7,12 +7,12 @@ namespace Plugin.MediaManager
internal class MediaButtonPlaybackController
{
private readonly ISystemMediaTransportControlsWrapper _systemMediaTransportControlsWrapper;
- private readonly IPlaybackController _playbackController;
+ private readonly IPlaybackControllerProvider _playbackControllerProvider;
- public MediaButtonPlaybackController(ISystemMediaTransportControlsWrapper systemMediaTransportControlsWrapper, IPlaybackController playbackController)
+ public MediaButtonPlaybackController(ISystemMediaTransportControlsWrapper systemMediaTransportControlsWrapper, IPlaybackControllerProvider playbackControllerProvider)
{
_systemMediaTransportControlsWrapper = systemMediaTransportControlsWrapper;
- _playbackController = playbackController;
+ _playbackControllerProvider = playbackControllerProvider;
_systemMediaTransportControlsWrapper.IsNextEnabled = true;
_systemMediaTransportControlsWrapper.IsPreviousEnabled = true;
@@ -38,19 +38,19 @@ private async void MediaControls_ButtonPressed(SystemMediaTransportControls send
switch (args.Button)
{
case SystemMediaTransportControlsButton.Next:
- await _playbackController.PlayNext();
+ await _playbackControllerProvider.PlaybackController.PlayNext();
break;
case SystemMediaTransportControlsButton.Previous:
- await _playbackController.PlayPreviousOrSeekToStart();
+ await _playbackControllerProvider.PlaybackController.PlayPreviousOrSeekToStart();
break;
case SystemMediaTransportControlsButton.Play:
- await _playbackController.Play();
+ await _playbackControllerProvider.PlaybackController.Play();
break;
case SystemMediaTransportControlsButton.Pause:
- await _playbackController.Pause();
+ await _playbackControllerProvider.PlaybackController.Pause();
break;
case SystemMediaTransportControlsButton.Stop:
- await _playbackController.Stop();
+ await _playbackControllerProvider.PlaybackController.Stop();
break;
}
}
diff --git a/MediaManager.UWP/MediaManagerImplementation.cs b/MediaManager.UWP/MediaManagerImplementation.cs
index 4cc47d8c..21ec1650 100644
--- a/MediaManager.UWP/MediaManagerImplementation.cs
+++ b/MediaManager.UWP/MediaManagerImplementation.cs
@@ -8,7 +8,7 @@ namespace Plugin.MediaManager
///
/// Implementation for Feature
///
- public class MediaManagerImplementation : MediaManagerBase
+ public class MediaManagerImplementation : MediaManagerBase, IPlaybackControllerProvider
{
private IAudioPlayer _audioPlayer;
private IVideoPlayer _videoPlayer;
@@ -17,7 +17,7 @@ public class MediaManagerImplementation : MediaManagerBase
public MediaManagerImplementation()
{
var systemMediaTransportControlsWrapper = new SystemMediaTransportControlsWrapper(SystemMediaTransportControls.GetForCurrentView());
- _mediaButtonPlaybackController = new MediaButtonPlaybackController(systemMediaTransportControlsWrapper, PlaybackController);
+ _mediaButtonPlaybackController = new MediaButtonPlaybackController(systemMediaTransportControlsWrapper, this);
_mediaButtonPlaybackController.SubscribeToNotifications();
}
diff --git a/MediaManager.UWP/Plugin.MediaManager.UWP.csproj b/MediaManager.UWP/Plugin.MediaManager.UWP.csproj
index 366d74a1..160e5207 100644
--- a/MediaManager.UWP/Plugin.MediaManager.UWP.csproj
+++ b/MediaManager.UWP/Plugin.MediaManager.UWP.csproj
@@ -113,6 +113,7 @@
CrossMediaManager.cs
+