From 92e0a8f1a49a015103479a20a293c0ce3e85667e Mon Sep 17 00:00:00 2001 From: nothingmn Date: Thu, 7 Oct 2010 21:19:05 -0700 Subject: [PATCH] Added Media Provider Interface and XBMC's implementation --- NzbDrone.Core/NzbDrone.Core.csproj | 2 + NzbDrone.Core/Providers/IMediaProvider.cs | 35 ++++++ NzbDrone.Core/Providers/XBMCMediaProvider.cs | 109 +++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 NzbDrone.Core/Providers/IMediaProvider.cs create mode 100644 NzbDrone.Core/Providers/XBMCMediaProvider.cs diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 0108f82fe..7ebdd1cec 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -149,6 +149,8 @@ + + diff --git a/NzbDrone.Core/Providers/IMediaProvider.cs b/NzbDrone.Core/Providers/IMediaProvider.cs new file mode 100644 index 000000000..00cda8db1 --- /dev/null +++ b/NzbDrone.Core/Providers/IMediaProvider.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Providers +{ + interface IMediaProvider + { + void Play(); + void Play(string Location); + void Play(string Location, bool AddToQueue); + void Pause(); + void Stop(); + + void Next(); + void Previous(); + void Seek(string RawTime); + void Seek(int Hour, int Minute, int Second); + void Seek(System.TimeSpan SeekTime); + + void Queue(string Location); + + System.Uri Uri { get; } + string UniqueDeviceName { get; } + OpenSource.UPnP.UPnPDevice Device { get; } + OpenSource.UPnP.AV.CpAVTransport Transport { get; } + string FriendlyName { get; } + + DateTime FirstSeen { get; } + DateTime LastSeen { get; } + bool IsActive { get; } + + } +} diff --git a/NzbDrone.Core/Providers/XBMCMediaProvider.cs b/NzbDrone.Core/Providers/XBMCMediaProvider.cs new file mode 100644 index 000000000..9bd16af05 --- /dev/null +++ b/NzbDrone.Core/Providers/XBMCMediaProvider.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Providers +{ + public class XBMCMediaProvider : IMediaProvider + { + public OpenSource.XBMC.XBMCAVDevice XBMCDevice{ get; set; } + public XBMCMediaProvider(OpenSource.XBMC.XBMCAVDevice XBMCDevice) + { + this.XBMCDevice = XBMCDevice; + } + + #region IAVDevice Members + + public DateTime FirstSeen { get { return XBMCDevice.FirstSeen; } } + public DateTime LastSeen { get { return XBMCDevice.LastSeen; } } + public bool IsActive + { + get + { + return XBMCDevice.IsActive; + } + } + +public void Play() + { + XBMCDevice.Play(); + } + public void Play(string Location) + { + XBMCDevice.Play(Location); + } + public void Play(string Location, bool AddToQueue) + { + XBMCDevice.Play(Location, AddToQueue); + } + public void Stop() + { + XBMCDevice.Stop(); + + } + + public void Next() + { + XBMCDevice.Next(); + } + public void Previous() + { + XBMCDevice.Previous(); + } + public void Seek(string RawTime) + { + XBMCDevice.Seek(RawTime); + } + public void Seek(int Hour, int Minute, int Second) + { + XBMCDevice.Seek(Hour, Minute, Second); + } + public void Seek(System.TimeSpan SeekTime) + { + XBMCDevice.Seek(SeekTime); + } + + + public void Queue(string Location) + { + XBMCDevice.Queue(Location); + } + + + public OpenSource.UPnP.UPnPDevice Device { + get { return XBMCDevice.Device; } + } + public void Pause() + { + XBMCDevice.Pause(); + } + + public System.Uri Uri + { + get { return XBMCDevice.Uri; } + } + public string UniqueDeviceName + { + get { return XBMCDevice.UniqueDeviceName; } + } + + public OpenSource.UPnP.AV.CpAVTransport Transport + { + get + { + return XBMCDevice.Transport; + } + } + + public string FriendlyName + { + get + { + return XBMCDevice.FriendlyName; + } + } + + #endregion + } +}