Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed duplicating of SWYH devices in system list #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SWYH/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ private void Application_Startup(object sender, StartupEventArgs e)
this.rendererDiscovery = new AVRendererDiscovery((new AVRendererDiscovery.DiscoveryHandler(RendererAddedSink)));
this.rendererDiscovery.OnRendererRemoved += new AVRendererDiscovery.DiscoveryHandler(new AVRendererDiscovery.DiscoveryHandler(RendererRemovedSink));
this.wasapiProvider = new WasapiProvider();
this.swyhDevice = new SwyhDevice();

if (!Guid.TryParse(SWYH.Properties.Settings.Default.UniqueDeviceName, out _))
{
SWYH.Properties.Settings.Default.UniqueDeviceName = Guid.NewGuid().ToString();
SWYH.Properties.Settings.Default.Save();
}

this.swyhDevice = new SwyhDevice(SWYH.Properties.Settings.Default.UniqueDeviceName);
this.swyhDevice.Start();
notifyIcon.ShowBalloonTip(2000, "Stream What You Hear is running", "Right-click on this icon to show the menu !", System.Windows.Forms.ToolTipIcon.Info);
}
Expand Down
15 changes: 15 additions & 0 deletions SWYH/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion SWYH/UPnP/SwyhDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal class SwyhDevice
public DvContentDirectory ContentDirectory { get; private set; }
public DvConnectionManager ConnectionManager { get; private set; }

public SwyhDevice()
public SwyhDevice(string UniqueDeviceName = "")
{
this.Device = UPnPDevice.CreateRootDevice(1800, 1.0, "\\");

Expand All @@ -63,6 +63,11 @@ public SwyhDevice()
this.Device.ModelNumber = string.Format("{0}.{1}", fileVersion.ProductMajorPart, fileVersion.ProductMinorPart);
this.Device.SerialNumber = string.Format("SWYH_UPNP_{0}{1}", fileVersion.ProductMajorPart, fileVersion.ProductMinorPart);

if (Guid.TryParse(UniqueDeviceName, out _))
{
this.Device.UniqueDeviceName = UniqueDeviceName;
}

this.Device.HasPresentation = true;
this.Device.PresentationURL = "about/swyh.html";
this.Device.DeviceURN = "urn:schemas-upnp-org:device:MediaServer:1";
Expand Down