Skip to content

Commit

Permalink
Merge pull request #32 from IranEG/master
Browse files Browse the repository at this point in the history
Adds support for MediaMonkey and Deezer. Fixes issue with Chrome extension button.
  • Loading branch information
pendo324 authored Feb 12, 2017
2 parents 66f6195 + d8af9cc commit bbb64eb
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,4 @@ ModelManifest.xml
/.rnd
/EssentialNowPlaying/nowplaying.min.js
/EssentialNowPlaying/nowplaying.js
/EssentialNowPlaying/MediaMonkeyHandler.cs
/EssentialNowPlaying/icon.ico
2 changes: 1 addition & 1 deletion Chrome Extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 21 additions & 2 deletions Chrome Extension/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ players = {
"play.spotify.com": spotify,
"soundcloud": soundcloud,
"tunein": tunein,
"youtube": youtube
"youtube": youtube,
"deezer": deezer
};

function mixcloud() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -206,7 +225,7 @@ function checkSupport() {
}

function addHTML() {
var html = "<div id='npiframe-container style='visibility:hidden'><iframe name='npiframe'></iframe></div><div class=NowPlayingContainer><style>.NowPlayingContainer{background-color:#343434;border:2px solid #3c3c3c;color:#f5f5f5;position:fixed;bottom:50px;right:30px;width:300px;min-height:100px;z-index:10000;}.NowPlayingHeader{margin:10px;line-height:18px;font-family:arial;font-size:16px}.NowPlayingBody{margin-top:15px;margin-left:10px;line-height:16px;font-family:arial;font-size:14px}.NowPlayingSupported{margin-left:65px;margin-top:-20px;line-height:16px;font-family:arial;font-size:14px}.NowPlayingSupported a:link{color:#09F}.NowPlayingSupported a:visited{color: #CC0099;}.NowPlayingButton{margin-left:10px;line-height:16px;font-family:arial;font-size:14px}</style><div><div class=NowPlayingHeader>OBS Now Playing</div><button class=NowPlayingButton>Start</button><div class=NowPlayingSupported></div><div class=NowPlayingBody>No song playing.</div></div></div>";
var html = "<div id='npiframe-container style='visibility:hidden'><iframe name='npiframe'></iframe></div><div class=NowPlayingContainer><style>.NowPlayingContainer{background-color:#343434;border:2px solid #3c3c3c;border-radius:4px;color:#f5f5f5;position:fixed;bottom:50px;right:30px;width:300px;min-height:100px;z-index:10000;}.NowPlayingHeader{margin:10px;line-height:18px;font-family:arial;font-size:16px}.NowPlayingBody{margin-top:15px;margin-bottom:10px;margin-left:10px;line-height:16px;font-family:arial;font-size:14px}.NowPlayingSupported{margin-left:70px;margin-top:-20px;line-height:16px;font-family:arial;font-size:14px}.NowPlayingSupported a:link{color:#09F}.NowPlayingSupported a:visited{color: #CC0099;}.NowPlayingButton{all:unset;background-color:#008CBA;margin-left:10px;line-height:16px;font-family:arial;font-size:14px;color:#FFFFFF;padding:5px 10px;border-radius:4px;cursor:pointer;}.NowPlayingButton:hover{background-color:#00BFED}</style><div><div class=NowPlayingHeader>OBS Now Playing</div><button class=NowPlayingButton>Start</button><div class=NowPlayingSupported></div><div class=NowPlayingBody>No song playing.</div></div></div>";
$('body').append(html);
}

Expand Down
6 changes: 4 additions & 2 deletions EssentialNowPlaying/Form1.Designer.cs

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

116 changes: 116 additions & 0 deletions EssentialNowPlaying/MediaMonkeyHandler.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
5 changes: 5 additions & 0 deletions EssentialNowPlaying/SourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit bbb64eb

Please sign in to comment.