Merged in rob's UPnP code
This commit is contained in:
commit
b112e28b80
Binary file not shown.
|
@ -143,12 +143,17 @@
|
|||
<Reference Include="System.XML" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL" />
|
||||
<Reference Include="UPnP, Version=1.0.3932.37442, Culture=neutral, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Entities\Notification\BasicNotification.cs" />
|
||||
<Compile Include="Entities\Notification\NotificationStatus.cs" />
|
||||
<Compile Include="Entities\Notification\NotificationType.cs" />
|
||||
<Compile Include="Providers\INotificationProvider.cs" />
|
||||
<Compile Include="Providers\IMediaDiscoveryProvider.cs" />
|
||||
<Compile Include="Providers\IMediaProvider.cs" />
|
||||
<Compile Include="Providers\MediaDiscoveryProvider.cs" />
|
||||
<Compile Include="Providers\XBMCMediaProvider.cs" />
|
||||
<Compile Include="Entities\Notification\ProgressNotification.cs" />
|
||||
<Compile Include="Providers\NotificationProvider.cs" />
|
||||
<Compile Include="SonicTrace.cs" />
|
||||
|
@ -223,6 +228,7 @@
|
|||
<Content Include="Libraries\TvdbLib.dll" />
|
||||
<Content Include="Libraries\TvdbLib.pdb" />
|
||||
<Content Include="Libraries\TvdbLib.XML" />
|
||||
<Content Include="Libraries\UPnP.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public interface IMediaDiscoveryProvider
|
||||
{
|
||||
bool DiscoveredMedia { get; }
|
||||
List<IMediaProvider> Providers { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public 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; }
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class MediaDiscoveryProvider : IMediaDiscoveryProvider
|
||||
{
|
||||
#region IMediaDiscoveryProvider Members
|
||||
|
||||
public bool DiscoveredMedia
|
||||
{
|
||||
get { return (OpenSource.UPnP.AudioVideoDevices.Instance.Devices.Count > 0); }
|
||||
}
|
||||
|
||||
private object _lock = new object();
|
||||
public List<IMediaProvider> Providers
|
||||
{
|
||||
get {
|
||||
lock (_lock)
|
||||
{
|
||||
List<IMediaProvider> list = new List<IMediaProvider>();
|
||||
foreach (OpenSource.UPnP.IAVDevice device in OpenSource.UPnP.AudioVideoDevices.Instance.Devices)
|
||||
{
|
||||
OpenSource.XBMC.XBMCAVDevice xbmc = (device as OpenSource.XBMC.XBMCAVDevice);
|
||||
if (xbmc != null)
|
||||
{
|
||||
XBMCMediaProvider newX = new XBMCMediaProvider(xbmc);
|
||||
list.Add(newX);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -51,6 +51,40 @@ namespace NzbDrone.Web.Controllers
|
|||
});
|
||||
}
|
||||
|
||||
public JsonResult MediaDetect()
|
||||
{
|
||||
Core.Providers.IMediaDiscoveryProvider disco = new Core.Providers.MediaDiscoveryProvider();
|
||||
return Json(new { Discovered = disco.DiscoveredMedia }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public JsonResult LightUpMedia()
|
||||
{
|
||||
Core.Providers.IMediaDiscoveryProvider disco = new Core.Providers.MediaDiscoveryProvider();
|
||||
IMediaProvider p = disco.Providers[0];
|
||||
return Json(new { ID = 0, HTML = "<span class='MediaRenderer XBMC'><span class='Play'>Play</span><span class='Pause'>Pause</span><span class='Stop'>Stop</span></span>" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public JsonResult ControlMedia()
|
||||
{
|
||||
Core.Providers.IMediaDiscoveryProvider disco = new Core.Providers.MediaDiscoveryProvider();
|
||||
IMediaProvider p = disco.Providers[0];
|
||||
string action = Request["Action"];
|
||||
switch (action)
|
||||
{
|
||||
case "Play":
|
||||
p.Play();
|
||||
break;
|
||||
case "Pause":
|
||||
p.Pause();
|
||||
break;
|
||||
case "Stop":
|
||||
p.Stop();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Json(new { Success=true}, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /Series/Details/5
|
||||
|
||||
|
|
|
@ -1,10 +1,52 @@
|
|||
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<NzbDrone.Core.Entities.Series>>" %>
|
||||
|
||||
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="JavascriptContent" runat="server">
|
||||
$(document).ready(function () {
|
||||
$("#Mediabox").bind("click", MediaBoxClick);
|
||||
setTimeout('MediaDetect();', 5000);
|
||||
});
|
||||
var Discovered = false;
|
||||
|
||||
function MediaDetect() {
|
||||
$.ajax({
|
||||
url: 'Series/MediaDetect',
|
||||
success: MediaDetectCallback
|
||||
});
|
||||
|
||||
}
|
||||
function MediaDetectCallback(data) {
|
||||
Discovered=data.Discovered;
|
||||
if(!Discovered)
|
||||
setTimeout('MediaDetect();', 10000);
|
||||
else
|
||||
LightUpMedia(data);
|
||||
}
|
||||
|
||||
function LightUpMedia(data) {
|
||||
$.ajax({
|
||||
url: 'Series/LightUpMedia',
|
||||
success: LightUpMediaSuccess
|
||||
});
|
||||
}
|
||||
function LightUpMediaSuccess(data) {
|
||||
$("#Mediabox").html(data.HTML);
|
||||
}
|
||||
function MediaBoxClick(args) {
|
||||
$.ajax({
|
||||
url: 'Series/ControlMedia',
|
||||
data: "Action=" + args.target.className
|
||||
});
|
||||
}
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
|
||||
Series
|
||||
</asp:Content>
|
||||
<asp:Content ID="Menue" ContentPlaceHolderID="ActionMenue" runat="server">
|
||||
<div id="Mediabox"></div>
|
||||
<%
|
||||
Html.Telerik().Menu().Name("telerikGrid").Items(items => { items.Add().Text("View Unmapped Folders").Action("Unmapped", "Series"); })
|
||||
.Items(items => items.Add().Text("Sync With Disk").Action("Sync", "Series"))
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
<%@ Import Namespace="Helpers" %>
|
||||
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<!--
|
||||
Design by Free CSS Templates
|
||||
|
@ -23,6 +22,33 @@ Released : 20100727
|
|||
Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.sitefinity.css")).Render();
|
||||
%>
|
||||
<link href="../../Content/style.css" rel="stylesheet" type="text/css" media="screen" />
|
||||
<style>
|
||||
.Mediabox
|
||||
{
|
||||
background:black;
|
||||
}
|
||||
.Play
|
||||
{
|
||||
cursor:pointer;
|
||||
padding:5px;
|
||||
|
||||
}
|
||||
.Pause
|
||||
{
|
||||
cursor:pointer;
|
||||
padding:5px;
|
||||
}
|
||||
.Stop
|
||||
{
|
||||
cursor:pointer;
|
||||
padding:5px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
<asp:ContentPlaceHolder ID="JavascriptContent" runat="server" />
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
|
|
Loading…
Reference in New Issue