Пример #1
0
 private void SongChangedHandler(object source, OnSongChanged e)
 {
     Dispatcher.Invoke(() =>
     {
         nowPlayingLabel.Content = e.GetSongName();
         playlistWindow.playlistBox.SelectedItem =
             pl.Shuffle ? playlistWindow.playlistBox.Items[pl.CurrPlaylingShuff] : playlistWindow.playlistBox.Items[pl.CurrPlaying];
         playlistWindow.playlistBox.ScrollIntoView(playlistWindow.playlistBox.SelectedItem);
     });
 }
Пример #2
0
 private void SongChangedHandler(object source, OnSongChanged e)
 {
     Dispatcher.Invoke(() =>
     {
         if (!eqOnCheckbox.IsChecked.Value)
         {
             return;
         }
         changeEQ();
     });
 }
Пример #3
0
            internal async void OnSongChange(GlobalSystemMediaTransportControlsSession session, MediaPropertiesChangedEventArgs args = null)
            {
                var props = await session.TryGetMediaPropertiesAsync();

                string song = $"{props.Title} | {props.Artist}";

                //This is needed because for some reason this method is invoked twice every song change
                if (LastSong != song && !(String.IsNullOrWhiteSpace(props.Title) && String.IsNullOrWhiteSpace(props.Artist)))
                {
                    LastSong = song;
                    OnSongChanged?.Invoke(this, props);
                }
            }
Пример #4
0
        private async void DoMemoryReadout()
        {
            while (running)
            {
                await Task.Delay(100);

                RSMemoryReadout newReadout = null;

                try
                {
                    //Read data from memory
                    newReadout = memReader.DoReadout();
                }
                catch (Exception e)
                {
                    if (running)
                    {
                        Logger.LogError("Error while reading memory: {0} {1}\r\n{2}", e.GetType(), e.Message, e.StackTrace);
                    }
                }

                if (newReadout == null)
                {
                    continue;
                }

                if (newReadout.songID != currentMemoryReadout.songID || (currentCDLCDetails == null || !currentCDLCDetails.IsValid()))
                {
                    var newDetails = cache.Get(newReadout.songID);

                    if (newDetails != null && newDetails.IsValid())
                    {
                        currentCDLCDetails = cache.Get(newReadout.songID);
                        OnSongChanged?.Invoke(this, new OnSongChangedArgs {
                            songDetails = currentCDLCDetails
                        });
                        currentCDLCDetails.Print();
                    }
                }

                newReadout.CopyTo(ref currentMemoryReadout);

                OnMemoryReadout?.Invoke(this, new OnMemoryReadoutArgs()
                {
                    memoryReadout = currentMemoryReadout
                });

                //Print memreadout if debug is enabled
                currentMemoryReadout.Print();
            }
        }
Пример #5
0
 protected virtual void OnOnSongChanged(Song e)
 {
     OnSongChanged?.Invoke(this, e);
 }
Пример #6
0
        private async Task <bool> UpdateCurrentDetails(string filepath)
        {
            //If the song has not changed, and the details object is valid, no need to update
            //Compare song id's in lowercase because the preview audio name is not guaranteed to match
            if (currentCDLCDetails.IsValid() && currentMemoryReadout.songID.ToLowerInvariant() == currentCDLCDetails.songID.ToLowerInvariant())
            {
                return(true);
            }

            //If songID is empty, we aren't gonna be able to do anything here
            if (currentMemoryReadout.songID == "")
            {
                return(true);
            }

            if (Logger.logSongDetails)
            {
                Logger.Log("Looking for '{0}' in psarc file: {1}", currentMemoryReadout.songID, filepath);
            }

            //Check if this psarc file is cached
            if (cache.Contains(filepath))
            {
                //Load from cache if it is
                currentCDLCDetails = cache.Load(filepath, currentMemoryReadout.songID);

                //If cache failed to load
                if (currentCDLCDetails == null)
                {
                    //Set invalid song details
                    currentCDLCDetails = new SongDetails();

                    //Return false, this is probably not the correct file
                    return(false);
                }

                //Print current details (if debug is enabled) and print warnings about this dlc
                currentCDLCDetails.Print();

                //Invoke event
                OnSongChanged?.Invoke(this, new OnSongChangedArgs()
                {
                    songDetails = currentCDLCDetails
                });

                //Exit function as data was handled from cache
                return(true);
            }

            //Read psarc data into the details object
            var allSongDetails = await Task.Run(() => PSARCUtil.ReadPSARCHeaderData(filepath));

            //If loading failed
            if (allSongDetails == null)
            {
                //Exit function
                return(true);
            }

            //If this is the songs.psarc file, we should merge RS1 DLC into it
            if (filepath.EndsWith("songs.psarc"))
            {
                //Really ugly way to find the rs1 dlc psarc
                string rs1dlcpath = filepath.Replace("songs.psarc", "dlc" + System.IO.Path.DirectorySeparatorChar + "rs1compatibilitydlc_p.psarc");

                //Read the rs1 dlc psarc
                var rs1SongDetails = await Task.Run(() => PSARCUtil.ReadPSARCHeaderData(rs1dlcpath));

                //If we got rs1 dlc arrangements
                if (rs1SongDetails != null)
                {
                    //Combine the two dictionaries
                    allSongDetails = allSongDetails.Concat(rs1SongDetails).ToDictionary(k => k.Key, v => v.Value);
                }
            }

            //If the song detail dictionary contains the song ID we are looking for
            if (allSongDetails.ContainsKey(currentMemoryReadout.songID))
            {
                //Assign current CDLC details
                currentCDLCDetails = allSongDetails[currentMemoryReadout.songID];
            }

            //Add this CDLC file to the cache
            cache.Add(filepath, allSongDetails);

            //Print current details (if debug is enabled) and print warnings about this dlc
            currentCDLCDetails.Print();

            //Invoke event
            OnSongChanged?.Invoke(this, new OnSongChangedArgs()
            {
                songDetails = currentCDLCDetails
            });

            return(true);
        }