Пример #1
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
        }
Пример #2
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;
        }