Updated UPnP so it does disco async, updated DiscoProviders to handle that approriately, Added JsonAction result with JS Ajax call for client side detection, on a timer for media controllers

This commit is contained in:
nothingmn 2010-10-07 22:04:25 -07:00
parent 78dba9c668
commit dfbf13b868
7 changed files with 45 additions and 17 deletions

Binary file not shown.

View File

@ -144,9 +144,7 @@
<Reference Include="System.XML" /> <Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL" /> <Reference Include="TvdbLib, Version=0.8.8.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="UPnP"> <Reference Include="UPnP, Version=1.0.3932.37442, Culture=neutral, processorArchitecture=MSIL" />
<HintPath>Libraries\UPnP.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Providers\IMediaDiscoveryProvider.cs" /> <Compile Include="Providers\IMediaDiscoveryProvider.cs" />
@ -225,6 +223,7 @@
<Content Include="Libraries\TvdbLib.dll" /> <Content Include="Libraries\TvdbLib.dll" />
<Content Include="Libraries\TvdbLib.pdb" /> <Content Include="Libraries\TvdbLib.pdb" />
<Content Include="Libraries\TvdbLib.XML" /> <Content Include="Libraries\TvdbLib.XML" />
<Content Include="Libraries\UPnP.dll" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -5,9 +5,8 @@ using System.Text;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
interface IMediaDiscoveryProvider public interface IMediaDiscoveryProvider
{ {
void Discover();
bool DiscoveredMedia { get; } bool DiscoveredMedia { get; }
List<IMediaProvider> Providers { get; } List<IMediaProvider> Providers { get; }
} }

View File

@ -9,12 +9,6 @@ namespace NzbDrone.Core.Providers
{ {
#region IMediaDiscoveryProvider Members #region IMediaDiscoveryProvider Members
public void Discover()
{
//calling the static instance will kick off the discovery process
OpenSource.UPnP.AudioVideoDevices instance = OpenSource.UPnP.AudioVideoDevices.Instance;
}
public bool DiscoveredMedia public bool DiscoveredMedia
{ {
get { return (OpenSource.UPnP.AudioVideoDevices.Instance.Devices.Count > 0); } get { return (OpenSource.UPnP.AudioVideoDevices.Instance.Devices.Count > 0); }

View File

@ -50,6 +50,12 @@ namespace NzbDrone.Web.Controllers
}); });
} }
public JsonResult MediaDetect()
{
Core.Providers.IMediaDiscoveryProvider disco = new Core.Providers.MediaDiscoveryProvider();
return Json(new { Discovered = disco.DiscoveredMedia }, JsonRequestBehavior.AllowGet);
}
// //
// GET: /Series/Details/5 // GET: /Series/Details/5

View File

@ -2,8 +2,36 @@
<%@ Import Namespace="Telerik.Web.Mvc.UI" %> <%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<%@ Import Namespace="NzbDrone.Core.Repository" %> <%@ Import Namespace="NzbDrone.Core.Repository" %>
<asp:Content ID="Content3" ContentPlaceHolderID="JavascriptContent" runat="server">
$(document).ready(function () {
setTimeout(MediaDetect(), 5000);
$("#Title").bind("click", MediaDetect);
});
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) {
}
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Series <div id="Title">Series</div>
</asp:Content> </asp:Content>
<asp:Content ID="Menue" ContentPlaceHolderID="ActionMenue" runat="server"> <asp:Content ID="Menue" ContentPlaceHolderID="ActionMenue" runat="server">
<% <%
@ -11,8 +39,6 @@
.Items(items => items.Add().Text("Sync With Disk").Action("Sync", "Series")) .Items(items => items.Add().Text("Sync With Disk").Action("Sync", "Series"))
.Render(); .Render();
%> %>
sss
</asp:Content> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% <%

View File

@ -2,8 +2,7 @@
<%@ Import Namespace="Helpers" %> <%@ Import Namespace="Helpers" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %> <%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- <!--
Design by Free CSS Templates Design by Free CSS Templates
@ -23,6 +22,11 @@ Released : 20100727
Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.sitefinity.css")).Render(); 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" /> <link href="../../Content/style.css" rel="stylesheet" type="text/css" media="screen" />
<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> </head>
<body> <body>
<div id="header"> <div id="header">