diff --git a/.gitignore b/.gitignore index 3fcb463..869bba2 100644 --- a/.gitignore +++ b/.gitignore @@ -202,5 +202,4 @@ ModelManifest.xml /.rnd /EssentialNowPlaying/nowplaying.min.js /EssentialNowPlaying/nowplaying.js -/EssentialNowPlaying/MediaMonkeyHandler.cs /EssentialNowPlaying/icon.ico diff --git a/Chrome Extension/manifest.json b/Chrome Extension/manifest.json index b9bd6f6..578d033 100644 --- a/Chrome Extension/manifest.json +++ b/Chrome Extension/manifest.json @@ -3,7 +3,7 @@ "name": "Now Playing Companion", "description": "Browser helper for the desktop application, OBS Now Playing", - "version": "1.2.1", + "version": "1.3", "icons": { "48": "icon.png" diff --git a/Chrome Extension/worker.js b/Chrome Extension/worker.js index 456b94e..e0f7ca7 100644 --- a/Chrome Extension/worker.js +++ b/Chrome Extension/worker.js @@ -16,7 +16,8 @@ players = { "play.spotify.com": spotify, "soundcloud": soundcloud, "tunein": tunein, - "youtube": youtube + "youtube": youtube, + "deezer": deezer }; function mixcloud() { @@ -146,6 +147,24 @@ function youtube() { }; } +function deezer() { + var artist, song, songTitle; + var wp = "Deezer"; + + if($(document).find('.player-track-title').text() === undefined || $(document).find('.player-track-title').text() === null) { + songTitle = 'Paused'; + } else { + artist = $(document).find('.player-track-artist').text(); + song = $(document).find('.player-track-title').text(); + songTitle = artist.substr(3) + " - " + song; + } + + return { + song: songTitle, + webPlayer: wp + }; +} + // sets the song variable, send it to localhost and makes the // appropriate changes to the html object(s) // TODO: add the html shit @@ -206,7 +225,7 @@ function checkSupport() { } function addHTML() { - var html = "
"; + var html = " "; $('body').append(html); } diff --git a/EssentialNowPlaying/Form1.Designer.cs b/EssentialNowPlaying/Form1.Designer.cs index 01c4ed8..b694a94 100644 --- a/EssentialNowPlaying/Form1.Designer.cs +++ b/EssentialNowPlaying/Form1.Designer.cs @@ -147,7 +147,8 @@ private void InitializeComponent() "tunein", "VLC", "WinAmp", - "YouTube"}); + "YouTube", + "Deezer"}); this.mediaPlayerBox.Location = new System.Drawing.Point(8, 15); this.mediaPlayerBox.Name = "mediaPlayerBox"; this.mediaPlayerBox.Size = new System.Drawing.Size(121, 21); @@ -222,7 +223,8 @@ private void InitializeComponent() "tunein", "VLC", "WinAmp", - "YouTube"}); + "YouTube", + "Deezer"}); this.defaultMediaBox.Location = new System.Drawing.Point(8, 29); this.defaultMediaBox.Name = "defaultMediaBox"; this.defaultMediaBox.Size = new System.Drawing.Size(121, 21); diff --git a/EssentialNowPlaying/MediaMonkeyHandler.cs b/EssentialNowPlaying/MediaMonkeyHandler.cs new file mode 100644 index 0000000..6087d96 --- /dev/null +++ b/EssentialNowPlaying/MediaMonkeyHandler.cs @@ -0,0 +1,116 @@ +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Essential_Now_Playing +{ + class MediaMonkeyHandler : SourceHandler + { + private Process[] processlist; + private string path; + private bool noSong; + private bool bStop; + private bool isMMUp; + private TextBox preview; + private string oldName = null; + + public MediaMonkeyHandler(string p, TextBox preview) + { + path = p; + bStop = false; + this.preview = preview; + } + + private Process findMM() + { + Process MediaMonkey = null; + processlist = Process.GetProcessesByName("MediaMonkey"); + + if (processlist.Length == 0) + { + isMMUp = false; + Debug.WriteLine("\n\n\n\nDEBUG\n\n\n"); + return null; + } + else + { + foreach (Process process in processlist) + { + if (process.ProcessName == "MediaMonkey") + { + if (process.MainWindowTitle != "") + { + MediaMonkey = process; + //Debug.WriteLine("{0} + {1}", "DEBUG", MediaMonkey.MainWindowTitle); + noSong = false; + isMMUp = true; + if (process.MainWindowTitle == "MediaMonkey") + { + noSong = true; + } + } + } + else + { + isMMUp = false; + } + } + } + return MediaMonkey; + } + + async public override Task pollForSongChanges() + { + while (!bStop) + { + + try + { + Process s = findMM(); + + string songName = s.MainWindowTitle.Replace(" - MediaMonkey", "") + " "; + + if (!isMMUp) + { + writeToPath(path, "MediaMonkey not open", true); + } + else if (noSong) + { + writeToPath(path, "Paused", true); + + oldName = null; + } + else + { + + if (oldName != null) + { + if (string.Compare(oldName, songName) != 0) + { + writeToPath(path, songName, true); + oldName = songName; + } + } + else + { + writeToPath(path, songName, true); + oldName = songName; + } + } + } + catch (NullReferenceException) + { + writeToPath(path, "MediaMonkey not open", true); + } + + await Task.Delay(500); + } + } + + public override void stop() + { + bStop = true; + } + } +} \ No newline at end of file diff --git a/EssentialNowPlaying/SourceManager.cs b/EssentialNowPlaying/SourceManager.cs index bc613d5..893893b 100644 --- a/EssentialNowPlaying/SourceManager.cs +++ b/EssentialNowPlaying/SourceManager.cs @@ -86,6 +86,11 @@ public void newSourceHandler() wah = new WebAppHandler(path, preview, "Google Play"); wah.start(); break; + case "Deezer": + isWebPlayer = true; + wah = new WebAppHandler(path, preview, "Deezer"); + wah.start(); + break; default: break; }