Ejemplo n.º 1
0
        public static MuteFm.SoundPlayerInfo CreateWebWithCustomName(string title, string url)
        {
            SoundPlayerInfo playerInfo = CreateWeb(title, url);

            playerInfo.UserEditedName = true;
            return(playerInfo);
        }
Ejemplo n.º 2
0
        public static string GetFileName(SoundPlayerInfo bgm)
        {
            string folder   = "playericon";
            string fileName = folder + @"\" + bgm.Id + ".png";

            return(fileName);
        }
Ejemplo n.º 3
0
        public static MuteFm.SoundPlayerInfo CreateProgram(string name)
        {
            SoundPlayerInfo playerInfo = new SoundPlayerInfo();

            playerInfo.Name  = name;
            playerInfo.IsWeb = false;
            return(playerInfo);
        }
Ejemplo n.º 4
0
        public static MuteFm.SoundPlayerInfo CreateWeb(string title, string url)
        {
            SoundPlayerInfo playerInfo = new SoundPlayerInfo();

            playerInfo.IsWeb            = true;
            playerInfo.UrlOrCommandLine = url;
            playerInfo.Name             = title;
            return(playerInfo);
        }
Ejemplo n.º 5
0
 public static SoundPlayerInfo FindBgMusic(string url, MuteFmConfig config)
 {
     for (int i = 0; i < config.BgMusics.Length; i++)
     {
         SoundPlayerInfo playerInfo = config.BgMusics[i];
         if (playerInfo.UrlOrCommandLine == url) // TODO: better way of finding unique name?
         {
             return(playerInfo);
         }
     }
     return(null);
 }
Ejemplo n.º 6
0
        public static string GetFormattedTitle(SoundPlayerInfo playerInfo)
        {
            string title = playerInfo.Name;

            if ((playerInfo.IsWeb) && (playerInfo.UserEditedName == false))
            {
                string domainName = new Uri(playerInfo.UrlOrCommandLine).Host;
                if (domainName.StartsWith("www."))
                {
                    domainName = domainName.Substring(4);
                }
                title = domainName + ": " + playerInfo.Name;
            }
            return(title);
        }
Ejemplo n.º 7
0
        public SoundPlayerInfo GetActiveBgMusic()
        {
            SoundPlayerInfo activeBgMusic = null;

            for (int i = 0; i < BgMusics.Length; i++)
            {
                if (((long)BgMusics[i].Id == this.ActiveBgMusicId) && (BgMusics[i].Enabled == true))
                {
#if NOAWE
                    if (BgMusics[i].IsWeb)
                    {
                        continue;
                    }
#endif
                    activeBgMusic = BgMusics[i];
                    break;
                }
            }

            // If not found, arbitrarily choose the first one
            if (activeBgMusic == null)
            {
                for (int i = 0; i < BgMusics.Length; i++)
                {
#if NOAWE
                    if (BgMusics[i].IsWeb)
                    {
                        continue;
                    }
#endif

                    if (BgMusics[i].Enabled == true)
                    {
                        activeBgMusic = BgMusics[i];
                        break;
                    }
                }
            }

            // TODO: need a failsafe in case nothing else works (or test with no bg music)

            return(activeBgMusic);
        }
Ejemplo n.º 8
0
 public static MuteFm.SoundPlayerInfo CreateProgram(string name)
 {
     SoundPlayerInfo playerInfo = new SoundPlayerInfo();
     playerInfo.Name = name;
     playerInfo.IsWeb = false;
     return playerInfo;
 }
Ejemplo n.º 9
0
        public PlayerStateSendData(Operation validOperation, bool isVisible, bool isRunning, SoundPlayerInfo activeBgMusic, SoundPlayerInfo[] fgMusics, float bgMusicVolume, bool bgMusicMuted, bool userWantsBgMusic, bool autoMuted, bool autoMutingEnabled, bool foregroundSoundPlaying, float masterVol, bool masterMuted)
        {
            //string bgMusicImage = ""; //TODO

            TrackName   = SmartVolManagerPackage.BgMusicManager.TrackName;
            AlbumArtUrl = SmartVolManagerPackage.BgMusicManager.AlbumArtFileName;
            AllowPlay   = false;
            AllowPause  = false;
            AllowMute   = !bgMusicMuted;
            AllowUnmute = bgMusicMuted;
            switch (validOperation)
            {
            case Operation.Play:
                AllowPlay = true; break;

            case Operation.Pause:
                AllowPause = true; break;

            // case Operation.Mute:
            //     AllowMute = true; break;
            // case Operation.Unmute:
            //     AllowUnmute = true; break;
            default:
                AllowPlay = true; break;
            }
            if (AllowUnmute && AllowPlay && autoMuted)
            {
                AllowUnmute = false;
            }

            AllowStop      = isRunning;
            AllowShow      = true;
            AllowHide      = false; // TODO  isVisible; (stop supporting it...)
            AllowExit      = true;
            AllowPrevTrack = !autoMuted && (activeBgMusic.PrevSongCommand != "");
            AllowNextTrack = !autoMuted && (activeBgMusic.NextSongCommand != "");
            AllowShuffle   = !autoMuted && (activeBgMusic.ShuffleCommand != "");
            AllowLike      = !autoMuted && (activeBgMusic.LikeCommand != "");
            AllowDislike   = !autoMuted && (activeBgMusic.DislikeCommand != "");
            AllowSettings  = true;

            ActiveBgMusicId    = activeBgMusic.Id;
            ActiveBgMusicTitle = SoundPlayerInfoUtility.GetFormattedTitle(activeBgMusic);
            ActiveBgMusicImage = WebServer.GetFileAsBase64String(@"playericon\" + activeBgMusic.Id + ".png");

            List <string> fgMusicTitleList     = new List <string>();
            List <long>   fgMusicIdList        = new List <long>();
            List <float>  fgMusicVolumeList    = new List <float>();
            List <bool>   fgMusicIsMutedList   = new List <bool>();
            List <bool>   fgMusicIsActiveList  = new List <bool>();
            List <bool>   fgMusicIgnoreList    = new List <bool>();
            List <bool>   fgMusicAllowAsBgList = new List <bool>();
            List <string> fgMusicImageList     = new List <string>();

            if (fgMusics.Length > 0)
            {
                for (int i = 0; i < fgMusics.Length; i++)
                {
                    if (fgMusics[i].Enabled)
                    {
                        float fgMusicVol       = 0.5f;
                        bool  fgMusicMuted     = false;
                        bool  fgMusicIsActive  = false;
                        bool  fgMusicIgnore    = false;
                        bool  fgMusicAllowAsBg = (fgMusics[i].ShortProcessName != "");
                        //bool fgMusicAllowAsBg = (fgMusics[i].ShortProcessName != "chrome") && (fgMusics[i].ShortProcessName != "firefox") && (fgMusics[i].ShortProcessName != "");

                        //bool include = false;
                        if ((SmartVolManagerPackage.BgMusicManager.FgMusicVol.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicMuted.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicIsActive.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicIgnore.Keys.Contains(fgMusics[i].Id)))
                        {
                            SmartVolManagerPackage.BgMusicManager.FgMusicVol.TryGetValue(fgMusics[i].Id, out fgMusicVol);
                            SmartVolManagerPackage.BgMusicManager.FgMusicMuted.TryGetValue(fgMusics[i].Id, out fgMusicMuted);
                            SmartVolManagerPackage.BgMusicManager.FgMusicIsActive.TryGetValue(fgMusics[i].Id, out fgMusicIsActive);
                            SmartVolManagerPackage.BgMusicManager.FgMusicIgnore.TryGetValue(fgMusics[i].Id, out fgMusicIgnore);
                            //include = true;
                        }
                        fgMusicImageList.Add(WebServer.GetFileAsBase64String(@"playericon\" + fgMusics[i].Id + ".png"));

                        //if (include)
                        //{
                        fgMusicTitleList.Add(SoundPlayerInfoUtility.GetFormattedTitle(fgMusics[i]));
                        fgMusicIdList.Add(fgMusics[i].Id);

                        fgMusicVolumeList.Add(fgMusicVol);
                        fgMusicIsMutedList.Add(fgMusicMuted);
                        fgMusicIsActiveList.Add(fgMusicIsActive);
                        fgMusicIgnoreList.Add(fgMusicIgnore);
                        fgMusicAllowAsBgList.Add(fgMusicAllowAsBg);
                        //}
                    }
                }
            }
            fgMusicTitles     = fgMusicTitleList.ToArray();
            fgMusicIds        = fgMusicIdList.ToArray();
            fgMusicVolumes    = fgMusicVolumeList.ToArray();
            fgMusicIsMuteds   = fgMusicIsMutedList.ToArray();
            fgMusicIsActives  = fgMusicIsActiveList.ToArray();
            fgMusicIgnores    = fgMusicIgnoreList.ToArray();
            fgMusicAllowAsBgs = fgMusicAllowAsBgList.ToArray();
            fgMusicImages     = fgMusicImageList.ToArray();

            if (fgMusicIgnores.Length != fgMusicIds.Length)
            {
                int x = 0;
                x++;
            }

            BgMusicVolume          = bgMusicVolume;
            BgMusicMuted           = bgMusicMuted;
            UserWantsBgMusic       = userWantsBgMusic;
            AutoMuted              = autoMuted;
            AutoMutingEnabled      = autoMutingEnabled;
            ForegroundSoundPlaying = foregroundSoundPlaying;

            MasterVol   = masterVol;
            MasterMuted = masterMuted;
        }
Ejemplo n.º 10
0
        public static void InitDefaultsProcess(SoundPlayerInfo soundInfo, string procName)
        {
            switch (procName.ToLower())
            {
            case "foobar2000":
                soundInfo.AutoPlaysOnStartup = true;
                soundInfo.PlayCommand        = "$procname$ /playpause"; //changed 8/5/13
                soundInfo.PauseCommand       = "$procname$ /pause";
                soundInfo.PrevSongCommand    = "$procname$ /prev";
                soundInfo.NextSongCommand    = "$procname$ /next";
                soundInfo.LikeCommand        = "";
                soundInfo.DislikeCommand     = "";
                soundInfo.OnLoadCommand      = "";
                soundInfo.StopCommand        = "$procname$ /stop";
                soundInfo.Name = "foobar2000";
                break;

            case "itunes":
                soundInfo.PauseCommand      = @"itunes:pause";
                soundInfo.PlayCommand       = @"itunes:play";
                soundInfo.NextSongCommand   = @"itunes:nexttrack";
                soundInfo.PrevSongCommand   = @"itunes:previoustrack";
                soundInfo.OnlyOneInstance   = true;
                soundInfo.Name              = "iTunes";
                soundInfo.KillAfterAutoMute = false;
                break;

            /*
             * case "vlc":
             * soundInfo.PauseCommand = @"vlc:pause";
             * soundInfo.PlayCommand = @"vlc:play";
             * soundInfo.NextSongCommand = @"vlc:nexttrack";
             * soundInfo.PrevSongCommand = @"vlc:previoustrack";
             * soundInfo.OnlyOneInstance = true;
             * soundInfo.Name = "VLC";
             * soundInfo.KillAfterAutoMute = false;
             * break;*/
            case "spotify":
                soundInfo.PauseCommand    = @"spotify:pause";
                soundInfo.PlayCommand     = @"spotify:play";
                soundInfo.NextSongCommand = @"spotify:nexttrack";
                soundInfo.PrevSongCommand = @"spotify:previoustrack";
                soundInfo.Name            = "Spotify";
                break;

            case "wmplayer":
                soundInfo.PauseCommand    = @"wmplayer:pause";
                soundInfo.PlayCommand     = @"wmplayer:play";
                soundInfo.NextSongCommand = @"wmplayer:nexttrack";
                soundInfo.PrevSongCommand = @"wmplayer:previoustrack";
                soundInfo.StopCommand     = @"wmplayer:stop";
                soundInfo.Name            = "Windows Media Player";
                break;

            case "zune":
                soundInfo.PauseCommand    = @"zune:pause";
                soundInfo.PlayCommand     = @"zune:play";
                soundInfo.NextSongCommand = @"zune:nexttrack";
                soundInfo.PrevSongCommand = @"zune:previoustrack";
                soundInfo.StopCommand     = @"zune:stop";
                soundInfo.Name            = "Zune";
                break;

            case "winamp":
                soundInfo.PauseCommand    = @"winamp:pause";
                soundInfo.PlayCommand     = @"winamp:play";
                soundInfo.NextSongCommand = @"winamp:nexttrack";
                soundInfo.PrevSongCommand = @"winamp:previoustrack";
                soundInfo.Name            = "WinAmp";
                break;

            default:
                soundInfo.AutoPlaysOnStartup = true;
                soundInfo.PlayCommand        = "";
                soundInfo.PauseCommand       = "";
                soundInfo.PrevSongCommand    = "";
                soundInfo.NextSongCommand    = "";
                soundInfo.LikeCommand        = "";
                soundInfo.DislikeCommand     = "";
                soundInfo.OnLoadCommand      = "";
                soundInfo.StopCommand        = "";
                break;
            }
        }
Ejemplo n.º 11
0
        public PlayerStateSendData(Operation validOperation, bool isVisible, bool isRunning, SoundPlayerInfo activeBgMusic, SoundPlayerInfo[] fgMusics, float bgMusicVolume, bool bgMusicMuted, bool userWantsBgMusic, bool autoMuted, bool autoMutingEnabled, bool foregroundSoundPlaying, float masterVol, bool masterMuted)
        {
            //string bgMusicImage = ""; //TODO

            TrackName = SmartVolManagerPackage.BgMusicManager.TrackName;
            AlbumArtUrl = SmartVolManagerPackage.BgMusicManager.AlbumArtFileName;
            AllowPlay = false;
            AllowPause = false;
            AllowMute = !bgMusicMuted;
            AllowUnmute = bgMusicMuted;
            switch (validOperation)
            {
                case Operation.Play:
                    AllowPlay = true; break;
                case Operation.Pause:
                    AllowPause = true; break;
               // case Operation.Mute:
               //     AllowMute = true; break;
               // case Operation.Unmute:
               //     AllowUnmute = true; break;
                default:
                    AllowPlay = true; break;
            }
            if (AllowUnmute && AllowPlay && autoMuted)
                AllowUnmute = false;

            AllowStop = isRunning;
            AllowShow = true;
            AllowHide = false; // TODO  isVisible; (stop supporting it...)
            AllowExit = true;
            AllowPrevTrack = !autoMuted && (activeBgMusic.PrevSongCommand != "");
            AllowNextTrack = !autoMuted && (activeBgMusic.NextSongCommand != "");
            AllowShuffle = !autoMuted && (activeBgMusic.ShuffleCommand != "");
            AllowLike = !autoMuted && (activeBgMusic.LikeCommand != "");
            AllowDislike = !autoMuted && (activeBgMusic.DislikeCommand != "");
            AllowSettings = true;

            ActiveBgMusicId = activeBgMusic.Id;
            ActiveBgMusicTitle = SoundPlayerInfoUtility.GetFormattedTitle(activeBgMusic);
            ActiveBgMusicImage = WebServer.GetFileAsBase64String(@"playericon\" + activeBgMusic.Id + ".png");

            List<string> fgMusicTitleList = new List<string>();
            List<long> fgMusicIdList = new List<long>();
            List<float> fgMusicVolumeList = new List<float>();
            List<bool> fgMusicIsMutedList = new List<bool>();
            List<bool> fgMusicIsActiveList = new List<bool>();
            List<bool> fgMusicIgnoreList = new List<bool>();
            List<bool> fgMusicAllowAsBgList = new List<bool>();
            List<string> fgMusicImageList = new List<string>();

            if (fgMusics.Length > 0)
            {
                for (int i = 0; i < fgMusics.Length; i++)
                {
                    if (fgMusics[i].Enabled)
                    {
                        float fgMusicVol = 0.5f;
                        bool fgMusicMuted = false;
                        bool fgMusicIsActive = false;
                        bool fgMusicIgnore = false;
                        bool fgMusicAllowAsBg = (fgMusics[i].ShortProcessName != "");
                        //bool fgMusicAllowAsBg = (fgMusics[i].ShortProcessName != "chrome") && (fgMusics[i].ShortProcessName != "firefox") && (fgMusics[i].ShortProcessName != "");

                        //bool include = false;
                        if ((SmartVolManagerPackage.BgMusicManager.FgMusicVol.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicMuted.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicIsActive.Keys.Contains(fgMusics[i].Id)) &&
                            (SmartVolManagerPackage.BgMusicManager.FgMusicIgnore.Keys.Contains(fgMusics[i].Id)))
                        {
                            SmartVolManagerPackage.BgMusicManager.FgMusicVol.TryGetValue(fgMusics[i].Id, out fgMusicVol);
                            SmartVolManagerPackage.BgMusicManager.FgMusicMuted.TryGetValue(fgMusics[i].Id, out fgMusicMuted);
                            SmartVolManagerPackage.BgMusicManager.FgMusicIsActive.TryGetValue(fgMusics[i].Id, out fgMusicIsActive);
                            SmartVolManagerPackage.BgMusicManager.FgMusicIgnore.TryGetValue(fgMusics[i].Id, out fgMusicIgnore);
                            //include = true;
                        }
                        fgMusicImageList.Add(WebServer.GetFileAsBase64String(@"playericon\" + fgMusics[i].Id + ".png"));

                        //if (include)
                        //{
                            fgMusicTitleList.Add(SoundPlayerInfoUtility.GetFormattedTitle(fgMusics[i]));
                            fgMusicIdList.Add(fgMusics[i].Id);

                            fgMusicVolumeList.Add(fgMusicVol);
                            fgMusicIsMutedList.Add(fgMusicMuted);
                            fgMusicIsActiveList.Add(fgMusicIsActive);
                            fgMusicIgnoreList.Add(fgMusicIgnore);
                            fgMusicAllowAsBgList.Add(fgMusicAllowAsBg);
                        //}
                    }
                }
            }
            fgMusicTitles = fgMusicTitleList.ToArray();
            fgMusicIds= fgMusicIdList.ToArray();
            fgMusicVolumes = fgMusicVolumeList.ToArray();
            fgMusicIsMuteds = fgMusicIsMutedList.ToArray();
            fgMusicIsActives = fgMusicIsActiveList.ToArray();
            fgMusicIgnores = fgMusicIgnoreList.ToArray();
            fgMusicAllowAsBgs = fgMusicAllowAsBgList.ToArray();
            fgMusicImages = fgMusicImageList.ToArray();

            if (fgMusicIgnores.Length != fgMusicIds.Length)
            {
                int x = 0;
                x++;
            }

            BgMusicVolume = bgMusicVolume;
            BgMusicMuted = bgMusicMuted;
            UserWantsBgMusic = userWantsBgMusic;
            AutoMuted = autoMuted;
            AutoMutingEnabled = autoMutingEnabled;
            ForegroundSoundPlaying = foregroundSoundPlaying;

            MasterVol = masterVol;
            MasterMuted = masterMuted;
        }
Ejemplo n.º 12
0
        public static void InitDefaultsWeb(SoundPlayerInfo soundInfo)
        {
            switch (soundInfo.UrlOrCommandLine)
            {
                case "http://www.pandora.com":
                    soundInfo.PlayCommand = "$('.playButton').click();";
                    soundInfo.PauseCommand = "$('.pauseButton').click();";
                    soundInfo.NextSongCommand = "$('.skipButton').click();";
                    soundInfo.LikeCommand = "$('.thumbUpButton').click();";
                    soundInfo.DislikeCommand = "$('.thumbDownButton').click();";
                    //soundInfo.OnLoadCommand = "var imListening = function(){$('.still_listening.button.btn_bg').click();setTimeout(imListening,1000);return true;};";
                    soundInfo.StopCommand = "";
                    break;
                case "http://www.grooveshark.com":
                    soundInfo.PlayCommand = "var obj = Grooveshark.getCurrentSongStatus(); if (obj.status === 'paused') Grooveshark.togglePlayPause();";
                    soundInfo.PauseCommand = "Grooveshark.pause();";
                    soundInfo.NextSongCommand = "Grooveshark.next();";
                    soundInfo.PrevSongCommand = "Grooveshark.previous();";
                    soundInfo.StopCommand = "";
                    break;
                case "http://www.rdio.com":
                    soundInfo.PlayCommand = " if ($('.playing').length === 0) { $('.play_pause').click(); }";
                    soundInfo.PauseCommand = "if ($('.playing').length === 1) { $('.play_pause').click(); }";
                    soundInfo.NextSongCommand = "$('.next').click();";
                    soundInfo.PrevSongCommand = "$('.prev').click();";
                    // this just toggles shuffle rdioBG.ShuffleCommand = "$('.shuffle').click();";
                    soundInfo.OnLoadCommand = "var takeControl = function(){$('.uncontrollable_player').find('.icon').click();};setTimeout(takeControl,1000);";
                    soundInfo.StopCommand = "";
                    break;
                case "http://www.mog.com":
                    soundInfo.PlayCommand = "var node = document.getElementById('play'); if (document.getElementsByClassName('pause').length == 0) { node.click(); }";
                    soundInfo.PauseCommand = "var node = document.getElementById('play'); if (document.getElementsByClassName('pause').length != 0) { node.click(); }";
                    soundInfo.NextSongCommand = "document.getElementById('next').click();";
                    soundInfo.PrevSongCommand = "document.getElementById('previous').click();";
                    soundInfo.StopCommand = "";
                    break;
                case "http://www.last.fm":
                    string lastFmGeneralCode = "var getButton = function(text) { var controls = document.getElementsByClassName('radiocontrol'); for (i = 0; i < controls.length; i++) { if (controls[i].text === text) return controls[i]; } return null; };";
                    soundInfo.PlayCommand = lastFmGeneralCode + "getButton('Resume Radio').click();";
                    soundInfo.PauseCommand = lastFmGeneralCode + "getButton('Pause Radio').click();";
                    soundInfo.NextSongCommand = lastFmGeneralCode + "getButton('Skip Track').click();";
                    soundInfo.OnLoadCommand = "var takeControl = function(){$('.uncontrollable_player').find('.icon').click();};setTimeout(takeControl,1000);";
                    soundInfo.StopCommand = "";
                    break;
                case "http://www.musicfellas.com":
                    soundInfo.PlayCommand = "if (!musicfellas.viewModel.playlist.isPlaying()) { musicfellas.viewModel.playlist.pause(); }";
                    soundInfo.PauseCommand = "if (musicfellas.viewModel.playlist.isPlaying()) { musicfellas.viewModel.playlist.pause(); }";

                    soundInfo.PrevSongCommand = "musicfellas.viewModel.playlist.prev();";
                    soundInfo.NextSongCommand = "musicfellas.viewModel.playlist.next();";
                    soundInfo.StopCommand = "musicfellas.viewModel.playlist.stop();";
                    break;
            }

            if (soundInfo.PauseCommand != "")
                soundInfo.KillAfterAutoMute = false;
        }
Ejemplo n.º 13
0
        public static string GetFileName(SoundPlayerInfo bgm)
        {
            string folder = "playericon";
            string fileName = folder + @"\" + bgm.Id + ".png";

            return fileName;
        }
Ejemplo n.º 14
0
        public static void GenerateIconImage(SoundPlayerInfo bgm, bool force)
        {
            string folder   = "playericon";
            string fileName = folder + @"\" + bgm.Id + ".png";

            System.Drawing.Bitmap bitmap;

            try
            {
                if (bgm.Name == "System Sounds")
                {
                    if (_iconContents.TryGetValue(@"mixer\windows.png", out bitmap) == false)
                    {
                        string tempFileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\mixer\windows.png";
                        if (System.IO.File.Exists(tempFileName))
                        {
                            bitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(tempFileName);
                            _iconContents[@"mixer\windows.png"] = bitmap;
                        }
                    }
                }
                else
                {
                    System.Drawing.Icon icon = null;
                    int x = 0;
                    if (bgm.IconPath != "")
                    {
                        x = x + 1;
                    }
                    string path = bgm.IconPath != "" ? bgm.IconPath : bgm.UrlOrCommandLine;
                    if ((bgm.IconPath == "") && (bgm.UrlOrCommandLine.StartsWith("http://")))
                    {
                        path = @"http://getfavicon.appspot.com/" + path;
                    }
                    if ((bgm.IconPath == "") && (bgm.UrlOrCommandLine.StartsWith("https://")))
                    {
                        path = @"https://getfavicon.appspot.com/" + path;
                    }

                    if (_iconContents.TryGetValue(path, out bitmap) == false)
                    {
                        if ((path.ToLower().StartsWith("http://")) || (path.ToLower().StartsWith("https://")))
                        {
                            string tempFile = System.IO.Path.GetTempFileName();
                            var    client   = new System.Net.WebClient();
                            client.DownloadFile(path, tempFile);
                            icon = System.Drawing.Icon.ExtractAssociatedIcon(tempFile);
                            System.IO.File.Delete(tempFile);
                        }
                        else
                        {
                            if (System.IO.File.Exists(path))
                            {
                                icon = GetIconOldSchool(path);
                            }
                            //icon = System.Drawing.Icon.ExtractAssociatedIcon(path);
                        }
                        if (icon != null)
                        {
                            bitmap = icon.ToBitmap();
                        }
                        _iconContents[path] = bitmap;
//                        bitmap.Save("C://foo.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                    }
                }
                if ((force) || ((bitmap != null) && (WebServer.RetrieveFile(fileName) == null)))
                {
                    byte[] result;
                    using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                    {
                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        result = stream.ToArray();
                    }
                    WebServer.StoreFile(fileName, result);
                }

//                if (bitmap == null)
//                    bgm.Enabled = false;
            }
            catch (Exception ex)
            {
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogMsg("Error generating icon file for bgmusic " + bgm.GetName());
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
//                bgm.Enabled = false;
            }
        }
Ejemplo n.º 15
0
 public static MuteFm.SoundPlayerInfo CreateWeb(string title, string url)
 {
     SoundPlayerInfo playerInfo = new SoundPlayerInfo();
     playerInfo.IsWeb = true;
     playerInfo.UrlOrCommandLine = url;
     playerInfo.Name = title;
     return playerInfo;
 }
Ejemplo n.º 16
0
        public static void GenerateIconImage(SoundPlayerInfo bgm, bool force)
        {
            string folder = "playericon";
            string fileName = folder + @"\" + bgm.Id + ".png";

            System.Drawing.Bitmap bitmap;

            try
            {
                if (bgm.Name == "System Sounds")
                {
                    if (_iconContents.TryGetValue(@"mixer\windows.png", out bitmap) == false)
                    {
                        string tempFileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\mixer\windows.png";
                        if (System.IO.File.Exists(tempFileName))
                        {
                            bitmap = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(tempFileName);
                            _iconContents[@"mixer\windows.png"] = bitmap;
                        }
                    }
                }
                else
                {
                    System.Drawing.Icon icon = null;
                    int x = 0;
                    if (bgm.IconPath != "")
                        x = x + 1;
                    string path = bgm.IconPath != "" ? bgm.IconPath : bgm.UrlOrCommandLine;
                    if ((bgm.IconPath == "") && (bgm.UrlOrCommandLine.StartsWith("http://")))
                        path = @"http://getfavicon.appspot.com/" + path;
                    if ((bgm.IconPath == "") && (bgm.UrlOrCommandLine.StartsWith("https://")))
                        path = @"https://getfavicon.appspot.com/" + path;

                    if (_iconContents.TryGetValue(path, out bitmap) == false)
                    {
                        if ((path.ToLower().StartsWith("http://")) || (path.ToLower().StartsWith("https://")))
                        {
                            string tempFile = System.IO.Path.GetTempFileName();
                            var client = new System.Net.WebClient();
                            client.DownloadFile(path, tempFile);
                            icon = System.Drawing.Icon.ExtractAssociatedIcon(tempFile);
                            System.IO.File.Delete(tempFile);
                        }
                        else
                        {
                            if (System.IO.File.Exists(path))
                                icon = GetIconOldSchool(path);
                                //icon = System.Drawing.Icon.ExtractAssociatedIcon(path);
                        }
                        if (icon != null)
                            bitmap = icon.ToBitmap();
                        _iconContents[path] = bitmap;
            //                        bitmap.Save("C://foo.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                    }
                }
                if ((force) || ((bitmap != null) && (WebServer.RetrieveFile(fileName) == null)))
                {
                    byte[] result;
                    using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
                    {
                        bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        result = stream.ToArray();
                    }
                    WebServer.StoreFile(fileName, result);
                }

            //                if (bitmap == null)
            //                    bgm.Enabled = false;
            }
            catch (Exception ex)
            {
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogMsg("Error generating icon file for bgmusic " + bgm.GetName());
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
            //                bgm.Enabled = false;
            }
        }
Ejemplo n.º 17
0
        public static MuteFm.MuteFmConfig CreateDefaultConfig()
        {
            MuteFm.MuteFmConfig defaultConfig = new MuteFm.MuteFmConfig();

            defaultConfig.BgMusics = new MuteFm.SoundPlayerInfo[0];

            defaultConfig.Id = Program.Identity;

            string executablePath = "";

            try
            {
                executablePath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Multimedia\WMPlayer", "Player.Path", "");
            }
            catch
            {
            }
            bool mplayerDetected = false;

            if (executablePath == "")
            {
                mplayerDetected = false;
                executablePath  = @"C:\Program Files (x86)\Windows Media Player\wmplayer.exe";
            }
            else
            {
                mplayerDetected = true;
            }

            // This demo entry will _always_ be created because there needs to be at least one background music
            SoundPlayerInfo demoBg = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateProgram("Demo music"), defaultConfig);

            demoBg.UrlOrCommandLine = executablePath;
            demoBg.ShortProcessName = "wmplayer";
            InitDefaultsProcess(demoBg, "wmplayer");
            //demoBg.CommandLineArgs = "\"" + Environment.SpecialFolder.CommonMusic + "\\Sample Music\\Maid with the Flaxen Hair.mp3\" /Task MediaLibrary";
            demoBg.CommandLineArgs    = "\"" + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\bwv849b.mid\"";
            demoBg.Name               = "Demo music";
            demoBg.AutoPlaysOnStartup = true;

            // TODO: set commandline here to play a specific song

            if (mplayerDetected)
            {
                SoundPlayerInfo wmplayerBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateProgram("Windows Media Player"), defaultConfig);
                wmplayerBG.UrlOrCommandLine = executablePath;
                wmplayerBG.ShortProcessName = "wmplayer";
                InitDefaultsProcess(wmplayerBG, "wmplayer");
            }


            //MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("Classical (YouTube)", "http://www.youtube.com/watch?v=ZYwqKKc1VCQ"), defaultConfig);

            SoundPlayerInfo pandoraBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("Pandora", "http://www.pandora.com"), defaultConfig);

            InitDefaultsWeb(pandoraBG);

            //SoundPlayerInfo grooveSharkBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("Grooveshark", "http://www.grooveshark.com"), defaultConfig);
            //InitDefaultsWeb(grooveSharkBG);

            //SoundPlayerInfo musicFellasBg = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("Musicfellas", "http://www.musicfellas.com"), defaultConfig);
            //musicFellasBg.IconPath = "http://musicfellas.com/favicon.png";
            //InitDefaultsWeb(musicFellasBg);

            SoundPlayerInfo rdioBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("Rdio", "http://www.rdio.com"), defaultConfig);

            rdioBG.IconPath = "http://www.rdio.com/favicon.ico";
            InitDefaultsWeb(rdioBG);

            SoundPlayerInfo lastfmBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("last.fm", "http://www.last.fm"), defaultConfig);

            InitDefaultsWeb(lastfmBG);

            SoundPlayerInfo mogBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateWebWithCustomName("MOG", "http://www.mog.com"), defaultConfig);

            //mogBG.IconPath = @"mixer\mog.png"; // TODO
            //mogBG.IconPath = "http://www.mog.com/favicon.ico";
            InitDefaultsWeb(mogBG);

            SoundPlayerInfo systemSoundBG = MuteFmConfigUtil.AddSoundPlayerInfo(MuteFmConfigUtil.CreateProgram("System Sounds"), defaultConfig);

            systemSoundBG.UrlOrCommandLine = "";
//            systemSoundBG.IconPath = @"mixer\windows.png";

            //getButton('Love Track').click();

            /*          //TODO: ex.fm doesn't seem to play music at all in awesomium
             *         BackgroundMusic exfmBG = MuteTunesConfigUtil.AddBgMusic(MuteTunesConfigUtil.CreateWebWithCustomName("ex.fm", "http://www.ex.fm/"), defaultConfig);
             *          rdioBG.PlayCommand = "if (document.getElementById('bottom_controls').getElementsByClassName('paused').length == 0) { document.getElementById('play_button').click(); }";
             *          rdioBG.PauseCommand = "if (document.getElementById('bottom_controls').getElementsByClassName('paused').length == 1) { document.getElementById('play_button').click(); }";
             *          rdioBG.NextSongCommand = "document.getElementById('next_button').click();";
             *          rdioBG.PrevSongCommand = "document.getElementById('prev_button').click()";
             */

            // broken since it doesn't maintain state

            /*BackgroundMusic burnFmBG = MuteTunesConfigUtil.AddBgMusic(MuteTunesConfigUtil.CreateWebWithCustomName("burn.fm", "http://www.burn.fm/"), defaultConfig);
             * burnFmBG.PlayCommand = "player.playVideo();";
             * burnFmBG.PauseCommand = "player.stopVideo();";
             * burnFmBG.PrevSongCommand = Resource1.burnfm_nextprevtrack + "nextPrevTrack(1);";
             * burnFmBG.OnLoadCommand = Resource1.burnfm_nextprevtrack;
             */

            MuteFmConfigUtil.LoadDefaultHotkeys(defaultConfig);

            // General settings
            defaultConfig.GeneralSettings = new MuteFm.GeneralSettings();
            defaultConfig.GeneralSettings.AutokillMutedTime        = MuteFmConfig.AutokillTimeoutDefault;
            defaultConfig.GeneralSettings.AutoShowAfterPlayTimeout = 4.0f;
            defaultConfig.GeneralSettings.FadeDownToLevel          = 0.0f; //TODO: not used yet
            defaultConfig.GeneralSettings.FadeInTime           = MuteFmConfig.FadeinTimeoutDefault;
            defaultConfig.GeneralSettings.FadeOutTime          = MuteFmConfig.FadeoutTimeoutDefault;
            defaultConfig.GeneralSettings.SilentShortDuration  = 0.25f;
            defaultConfig.GeneralSettings.SilentThreshold      = 0.01f;
            defaultConfig.GeneralSettings.NothingHeardTimeout  = 8.0f;
            defaultConfig.GeneralSettings.SoundPollIntervalInS = MuteFmConfig.SoundPollIntervalDefault;

            List <string> ignoreForAutoMuteList = new List <string>();

            ignoreForAutoMuteList.Add("camrecorder");
            ignoreForAutoMuteList.Add("");
            defaultConfig.IgnoreForAutoMute = ignoreForAutoMuteList.ToArray();
            defaultConfig.GeneralSettings.ActiveOverDurationInterval = MuteFmConfig.ActiveOverDurationIntervalDefault;
            defaultConfig.GeneralSettings.SilentDuration             = MuteFmConfig.SilentDurationDefault;

            MuteFm.MuteFmConfigUtil.Save(defaultConfig);

            return(defaultConfig);
        }
Ejemplo n.º 18
0
 public static void InitDefaultsProcess(SoundPlayerInfo soundInfo, string procName)
 {
     switch (procName.ToLower())
     {
         case "foobar2000":
             soundInfo.AutoPlaysOnStartup = true;
             soundInfo.PlayCommand = "$procname$ /playpause"; //changed 8/5/13
             soundInfo.PauseCommand = "$procname$ /pause";
             soundInfo.PrevSongCommand = "$procname$ /prev";
             soundInfo.NextSongCommand = "$procname$ /next";
             soundInfo.LikeCommand = "";
             soundInfo.DislikeCommand = "";
             soundInfo.OnLoadCommand = "";
             soundInfo.StopCommand = "$procname$ /stop";
             soundInfo.Name = "foobar2000";
             break;
         case "itunes":
             soundInfo.PauseCommand = @"itunes:pause";
             soundInfo.PlayCommand = @"itunes:play";
             soundInfo.NextSongCommand = @"itunes:nexttrack";
             soundInfo.PrevSongCommand = @"itunes:previoustrack";
             soundInfo.OnlyOneInstance = true;
             soundInfo.Name = "iTunes";
             soundInfo.KillAfterAutoMute = false;
             break;
             /*
         case "vlc":
             soundInfo.PauseCommand = @"vlc:pause";
             soundInfo.PlayCommand = @"vlc:play";
             soundInfo.NextSongCommand = @"vlc:nexttrack";
             soundInfo.PrevSongCommand = @"vlc:previoustrack";
             soundInfo.OnlyOneInstance = true;
             soundInfo.Name = "VLC";
             soundInfo.KillAfterAutoMute = false;
             break;*/
         case "spotify":
             soundInfo.PauseCommand = @"spotify:pause";
             soundInfo.PlayCommand = @"spotify:play";
             soundInfo.NextSongCommand = @"spotify:nexttrack";
             soundInfo.PrevSongCommand = @"spotify:previoustrack";
             soundInfo.Name = "Spotify";
             break;
         case "wmplayer":
             soundInfo.PauseCommand = @"wmplayer:pause";
             soundInfo.PlayCommand = @"wmplayer:play";
             soundInfo.NextSongCommand = @"wmplayer:nexttrack";
             soundInfo.PrevSongCommand = @"wmplayer:previoustrack";
             soundInfo.StopCommand = @"wmplayer:stop";
             soundInfo.Name = "Windows Media Player";
             break;
         case "zune":
             soundInfo.PauseCommand = @"zune:pause";
             soundInfo.PlayCommand = @"zune:play";
             soundInfo.NextSongCommand = @"zune:nexttrack";
             soundInfo.PrevSongCommand = @"zune:previoustrack";
             soundInfo.StopCommand = @"zune:stop";
             soundInfo.Name = "Zune";
             break;
         case "winamp":
             soundInfo.PauseCommand = @"winamp:pause";
             soundInfo.PlayCommand = @"winamp:play";
             soundInfo.NextSongCommand = @"winamp:nexttrack";
             soundInfo.PrevSongCommand = @"winamp:previoustrack";
             soundInfo.Name = "WinAmp";
             break;
         default:
             soundInfo.AutoPlaysOnStartup = true;
             soundInfo.PlayCommand = "";
             soundInfo.PauseCommand = "";
             soundInfo.PrevSongCommand = "";
             soundInfo.NextSongCommand = "";
             soundInfo.LikeCommand = "";
             soundInfo.DislikeCommand = "";
             soundInfo.OnLoadCommand = "";
             soundInfo.StopCommand = "";
             break;
     }
 }
Ejemplo n.º 19
0
        public static void InitDefaultsWeb(SoundPlayerInfo soundInfo)
        {
            switch (soundInfo.UrlOrCommandLine)
            {
            case "http://www.pandora.com":
                soundInfo.PlayCommand     = "$('.playButton').click();";
                soundInfo.PauseCommand    = "$('.pauseButton').click();";
                soundInfo.NextSongCommand = "$('.skipButton').click();";
                soundInfo.LikeCommand     = "$('.thumbUpButton').click();";
                soundInfo.DislikeCommand  = "$('.thumbDownButton').click();";
                //soundInfo.OnLoadCommand = "var imListening = function(){$('.still_listening.button.btn_bg').click();setTimeout(imListening,1000);return true;};";
                soundInfo.StopCommand = "";
                break;

            case "http://www.grooveshark.com":
                soundInfo.PlayCommand     = "var obj = Grooveshark.getCurrentSongStatus(); if (obj.status === 'paused') Grooveshark.togglePlayPause();";
                soundInfo.PauseCommand    = "Grooveshark.pause();";
                soundInfo.NextSongCommand = "Grooveshark.next();";
                soundInfo.PrevSongCommand = "Grooveshark.previous();";
                soundInfo.StopCommand     = "";
                break;

            case "http://www.rdio.com":
                soundInfo.PlayCommand     = " if ($('.playing').length === 0) { $('.play_pause').click(); }";
                soundInfo.PauseCommand    = "if ($('.playing').length === 1) { $('.play_pause').click(); }";
                soundInfo.NextSongCommand = "$('.next').click();";
                soundInfo.PrevSongCommand = "$('.prev').click();";
                // this just toggles shuffle rdioBG.ShuffleCommand = "$('.shuffle').click();";
                soundInfo.OnLoadCommand = "var takeControl = function(){$('.uncontrollable_player').find('.icon').click();};setTimeout(takeControl,1000);";
                soundInfo.StopCommand   = "";
                break;

            case "http://www.mog.com":
                soundInfo.PlayCommand     = "var node = document.getElementById('play'); if (document.getElementsByClassName('pause').length == 0) { node.click(); }";
                soundInfo.PauseCommand    = "var node = document.getElementById('play'); if (document.getElementsByClassName('pause').length != 0) { node.click(); }";
                soundInfo.NextSongCommand = "document.getElementById('next').click();";
                soundInfo.PrevSongCommand = "document.getElementById('previous').click();";
                soundInfo.StopCommand     = "";
                break;

            case "http://www.last.fm":
                string lastFmGeneralCode = "var getButton = function(text) { var controls = document.getElementsByClassName('radiocontrol'); for (i = 0; i < controls.length; i++) { if (controls[i].text === text) return controls[i]; } return null; };";
                soundInfo.PlayCommand     = lastFmGeneralCode + "getButton('Resume Radio').click();";
                soundInfo.PauseCommand    = lastFmGeneralCode + "getButton('Pause Radio').click();";
                soundInfo.NextSongCommand = lastFmGeneralCode + "getButton('Skip Track').click();";
                soundInfo.OnLoadCommand   = "var takeControl = function(){$('.uncontrollable_player').find('.icon').click();};setTimeout(takeControl,1000);";
                soundInfo.StopCommand     = "";
                break;

            case "http://www.musicfellas.com":
                soundInfo.PlayCommand  = "if (!musicfellas.viewModel.playlist.isPlaying()) { musicfellas.viewModel.playlist.pause(); }";
                soundInfo.PauseCommand = "if (musicfellas.viewModel.playlist.isPlaying()) { musicfellas.viewModel.playlist.pause(); }";

                soundInfo.PrevSongCommand = "musicfellas.viewModel.playlist.prev();";
                soundInfo.NextSongCommand = "musicfellas.viewModel.playlist.next();";
                soundInfo.StopCommand     = "musicfellas.viewModel.playlist.stop();";
                break;
            }

            if (soundInfo.PauseCommand != "")
            {
                soundInfo.KillAfterAutoMute = false;
            }
        }
Ejemplo n.º 20
0
 public static string GetFormattedTitle(SoundPlayerInfo playerInfo)
 {
     string title = playerInfo.Name;
     if ((playerInfo.IsWeb) && (playerInfo.UserEditedName == false))
     {
         string domainName = new Uri(playerInfo.UrlOrCommandLine).Host;
         if (domainName.StartsWith("www."))
             domainName = domainName.Substring(4);
         title = domainName + ": " + playerInfo.Name;
     }
     return title;
 }
Ejemplo n.º 21
0
        public BgMusicFavoritesSendData(SoundPlayerInfo[] bgMusics, bool autoMutingEnabled, bool foregroundSoundPlaying)
        {
            AutoMutingEnabled = autoMutingEnabled;
            ForegroundSoundPlaying = foregroundSoundPlaying;

            List<string> bgMusicTitleList = new List<string>();
            List<long> bgMusicIdList = new List<long>();
            List<string> bgMusicImageList = new List<string>();
            // TODO: maybe show these in LRU order?
            if (bgMusics.Length > 0)
            {
                for (int i = 0; i < bgMusics.Length; i++)
                {
                    if (bgMusics[i].Enabled)
                    {
                        bgMusicTitleList.Add(SoundPlayerInfoUtility.GetFormattedTitle(bgMusics[i]));
                        bgMusicIdList.Add(bgMusics[i].Id);
                        bgMusicImageList.Add(WebServer.GetFileAsBase64String(@"playericon\" + bgMusics[i].Id + ".png"));
                    }
                }
            }
            bgMusicTitles = bgMusicTitleList.ToArray();
            bgMusicIds = bgMusicIdList.ToArray();
            bgMusicImages = bgMusicImageList.ToArray(); // TODO-base64
        }