From e040504530cf027597a98b83bbd892442c91aa00 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:35:19 -0400 Subject: [PATCH 01/44] Create build.yml --- .github/workflows/build.yml | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0819d1a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,67 @@ +# This workflow will build, sign, and package a WinUI 3 MSIX desktop application +# built on .NET. + +name: WinUI 3 MSIX app + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + build: + + strategy: + matrix: + configuration: [Release] + platform: [x64, x86] + + runs-on: windows-latest + + env: + Solution_Name: Musium + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.0.x + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Restore the application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} + + - name: Decode the pfx + run: | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.BASE64_ENCODED_PFX }}") + $certificatePath = "GitHubActionsWorkflow.pfx" + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) + + - name: Create the app package + run: msbuild $env:Solution_Name /p:Configuration=$env:Configuration /p:Platform=$env:Platform /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true + env: + Appx_Bundle: Never + Appx_Package_Build_Mode: SideloadOnly + Appx_Package_Dir: Packages\ + Configuration: ${{ matrix.configuration }} + Platform: ${{ matrix.platform }} + + - name: Remove the pfx + run: Remove-Item -path GitHubActionsWorkflow.pfx + + - name: Upload MSIX package + uses: actions/upload-artifact@v2 + with: + name: MSIX Package + path: ${{ env.Solution_Name }}\\Packages From d7293a987570e4d7470e8a4f88f8df99de5ea37a Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:37:44 -0400 Subject: [PATCH 02/44] add build to dev branch --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0819d1a..81ad3b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,13 @@ name: WinUI 3 MSIX app on: push: - branches: [ main ] + branches: + - main + - dev pull_request: - branches: [ main ] + branches: + - main + - dev jobs: From aab4b392afb4732f679409bdd661115da25f1c12 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:38:54 -0400 Subject: [PATCH 03/44] Update build.yml --- .github/workflows/build.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81ad3b9..0399b08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,4 @@ -# This workflow will build, sign, and package a WinUI 3 MSIX desktop application -# built on .NET. - -name: WinUI 3 MSIX app +name: Build Musium Packaged on: push: @@ -29,7 +26,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 From 17bd69b4ad8f8eb5e87306ca63cb4d4b6f3133e5 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:39:53 -0400 Subject: [PATCH 04/44] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0399b08..020812b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,7 @@ jobs: run: Remove-Item -path GitHubActionsWorkflow.pfx - name: Upload MSIX package - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: MSIX Package path: ${{ env.Solution_Name }}\\Packages From fa8da2650d17150de3d252e2b6a5c29c63f84605 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:45:41 -0400 Subject: [PATCH 05/44] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 020812b..20fd24c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: configuration: [Release] - platform: [x64, x86] + platform: [x64, ARM64] runs-on: windows-latest @@ -39,7 +39,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + run: msbuild "$env:Solution_Name.sln" /t:Restore /p:Configuration=$env:Configuration env: Configuration: ${{ matrix.configuration }} From 0f34783f75d424fb19ea94d5e6d7730aae1a3c3d Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:50:55 -0400 Subject: [PATCH 06/44] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20fd24c..5eed4a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,7 @@ jobs: run: msbuild "$env:Solution_Name.sln" /t:Restore /p:Configuration=$env:Configuration env: Configuration: ${{ matrix.configuration }} + working-directory: './Musium' - name: Decode the pfx run: | From 0aa35e1385840d370d1f916d254cc4cd5faa8305 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:55:11 -0400 Subject: [PATCH 07/44] Update build.yml --- .github/workflows/build.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5eed4a3..223c7c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,22 +27,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - + - name: Install .NET Core uses: actions/setup-dotnet@v1 with: dotnet-version: 8.0.x - + - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.2 - + - name: Restore the application run: msbuild "$env:Solution_Name.sln" /t:Restore /p:Configuration=$env:Configuration env: + Solution_Name: Musium Configuration: ${{ matrix.configuration }} - working-directory: './Musium' - name: Decode the pfx run: | From 643225e8eb6bc8f88918f0f3429524b2bc8bb1e7 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:57:25 -0400 Subject: [PATCH 08/44] Update build.yml --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 223c7c2..a913b43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,8 @@ jobs: - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.2 - + - name: List files + run: ls -R - name: Restore the application run: msbuild "$env:Solution_Name.sln" /t:Restore /p:Configuration=$env:Configuration env: From 69f89b3cd6fdbfde918e0bce41f2b64e3330a1fd Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 13:59:30 -0400 Subject: [PATCH 09/44] please please please build --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a913b43..0682e47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,10 +35,9 @@ jobs: - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.2 - - name: List files - run: ls -R + - name: Restore the application - run: msbuild "$env:Solution_Name.sln" /t:Restore /p:Configuration=$env:Configuration + run: msbuild "$env:Solution_Name.slnx" /t:Restore /p:Configuration=$env:Configuration env: Solution_Name: Musium Configuration: ${{ matrix.configuration }} From 9602e68467e40d5b64cfd4261005c2dc24a17cf1 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:03:00 -0400 Subject: [PATCH 10/44] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0682e47..d8fc673 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: runs-on: windows-latest env: - Solution_Name: Musium + Solution_Name: Musium.slnx steps: - name: Checkout @@ -37,7 +37,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Restore the application - run: msbuild "$env:Solution_Name.slnx" /t:Restore /p:Configuration=$env:Configuration + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration env: Solution_Name: Musium Configuration: ${{ matrix.configuration }} From 33bdaadbc94e6b4e19b48d747b885662fd32247e Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:05:25 -0400 Subject: [PATCH 11/44] ples --- .github/workflows/build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8fc673..763f709 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: runs-on: windows-latest env: - Solution_Name: Musium.slnx + Solution_Name: Musium steps: - name: Checkout @@ -37,9 +37,8 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Restore the application - run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + run: msbuild "$env:Solution_Name.slnx" /t:Restore /p:Configuration=$env:Configuration env: - Solution_Name: Musium Configuration: ${{ matrix.configuration }} - name: Decode the pfx @@ -49,7 +48,7 @@ jobs: [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) - name: Create the app package - run: msbuild $env:Solution_Name /p:Configuration=$env:Configuration /p:Platform=$env:Platform /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true + run: msbuild "$env:Solution_Name.slnx" /p:Configuration=$env:Configuration /p:Platform=$env:Platform /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true env: Appx_Bundle: Never Appx_Package_Build_Mode: SideloadOnly From d059bd24e0306bcd7b83894812cbac870c6ee370 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:10:13 -0400 Subject: [PATCH 12/44] this is the one i can feel it --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 763f709..fc50f65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,4 +63,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: MSIX Package - path: ${{ env.Solution_Name }}\\Packages + path: ${{ github.workspace }}\\Packages From 828ceadd25ad48a742c3de898288ba718f85f34d Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:22:21 -0400 Subject: [PATCH 13/44] woops i need the certificate --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc50f65..c3b6021 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,8 +59,9 @@ jobs: - name: Remove the pfx run: Remove-Item -path GitHubActionsWorkflow.pfx - - name: Upload MSIX package + - name: Upload app packages and certificate uses: actions/upload-artifact@v4 with: - name: MSIX Package - path: ${{ github.workspace }}\\Packages + name: ${{ matrix.platform }}-App-Package + path: ${{ github.workspace }}/Packages/*.msix + ${{ github.workspace }}/Packages/*.cer From 4f3865633269e50f308102bf46c2bd4bbd281d11 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:27:30 -0400 Subject: [PATCH 14/44] Update build.yml --- .github/workflows/build.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3b6021..84e8edf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,9 +59,16 @@ jobs: - name: Remove the pfx run: Remove-Item -path GitHubActionsWorkflow.pfx - - name: Upload app packages and certificate + - name: Upload app packages uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-App-Package path: ${{ github.workspace }}/Packages/*.msix - ${{ github.workspace }}/Packages/*.cer + + - name: Upload certificate + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-App-Certificate + path: ${{ github.workspace }}/Packages/*.cer + + From d78824f7fd16145ae36d25b38719636855c9098e Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:33:32 -0400 Subject: [PATCH 15/44] Update build.yml --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84e8edf..295e14c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,7 +58,10 @@ jobs: - name: Remove the pfx run: Remove-Item -path GitHubActionsWorkflow.pfx - + + - name: List files + run: ls ${{ github.workspace }}/Packages/ -R + - name: Upload app packages uses: actions/upload-artifact@v4 with: From 2583c8c4784c654deabd3f7465b9b1a69f5c83f6 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:39:10 -0400 Subject: [PATCH 16/44] Update build.yml --- .github/workflows/build.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 295e14c..7bd8d0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,19 +59,17 @@ jobs: - name: Remove the pfx run: Remove-Item -path GitHubActionsWorkflow.pfx - - name: List files - run: ls ${{ github.workspace }}/Packages/ -R - - - name: Upload app packages + - name: Get file paths + id: get_paths + run: | + $files = Get-ChildItem -Path "Packages" -Include "*.msix", "*.cer" -Recurse | Select-Object -ExpandProperty FullName + echo "paths=$files" >> $env:GITHUB_OUTPUT + shell: pwsh + + - name: Upload app packages and certificate uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-App-Package - path: ${{ github.workspace }}/Packages/*.msix - - - name: Upload certificate - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.platform }}-App-Certificate - path: ${{ github.workspace }}/Packages/*.cer + path: ${{ steps.get_paths.outputs.paths }} From be6615d73d3155b41d9349347dfcb70e76944815 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:44:51 -0400 Subject: [PATCH 17/44] Update build.yml --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bd8d0e..6d2bd23 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,8 +62,9 @@ jobs: - name: Get file paths id: get_paths run: | - $files = Get-ChildItem -Path "Packages" -Include "*.msix", "*.cer" -Recurse | Select-Object -ExpandProperty FullName - echo "paths=$files" >> $env:GITHUB_OUTPUT + $files = Get-ChildItem -Path "Packages" -Include "*.msix", "*.cer" + $files -join "`n" | Out-File -FilePath "$env:GITHUB_OUTPUT" -Encoding utf8 -Append + echo "paths-output=true" >> $env:GITHUB_OUTPUT shell: pwsh - name: Upload app packages and certificate From d1081ce039c96b47367e1d70b25f232a69ffb0e6 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 14:58:16 -0400 Subject: [PATCH 18/44] Update build.yml --- .github/workflows/build.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d2bd23..baeded2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,19 +58,14 @@ jobs: - name: Remove the pfx run: Remove-Item -path GitHubActionsWorkflow.pfx - - - name: Get file paths - id: get_paths - run: | - $files = Get-ChildItem -Path "Packages" -Include "*.msix", "*.cer" - $files -join "`n" | Out-File -FilePath "$env:GITHUB_OUTPUT" -Encoding utf8 -Append - echo "paths-output=true" >> $env:GITHUB_OUTPUT - shell: pwsh - name: Upload app packages and certificate uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-App-Package - path: ${{ steps.get_paths.outputs.paths }} + path: | + ${{ github.workspace }}/Packages/**/*.msix + ${{ github.workspace }}/Packages/**/*.cer + !${{ github.workspace }}/Packages/**/Dependencies/** From e28d2feba062e7183a9a38d3a308ca5bb47ebf5b Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 16:41:06 -0400 Subject: [PATCH 19/44] and so the rewrite begins... removed some functions and made some new ones for the queue system --- Services/AudioService.cs | 101 ++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/Services/AudioService.cs b/Services/AudioService.cs index f45d238..772e91a 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -96,16 +96,37 @@ private AudioService() private List Database = new List(); public ObservableCollection Queue = new ObservableCollection(); - private List _nonShuffledQueueBackup = new List(); + private List _fullCurrentSongList= new List(); public List History = new List(); - public void ShuffleQueue() + public void PlaySongList(List inputSongList, Song startingSong) { - var rng = new Random(); - for (int i = Queue.Count - 1; i > 0; i--) + bool shuffled = CurrentShuffleState == ShuffleState.Shuffle; + var songList = new List(inputSongList); + songList.Remove(startingSong); + + _fullCurrentSongList = inputSongList; + + if (shuffled) shuffleSongList(songList); + ReplaceQueueWithList(songList); + PlaySong(startingSong); + } + private void shuffleSongList(List list) + { + for (int i = list.Count - 1; i > 0; i--) { - int k = rng.Next(i + 1); - Queue.Move(k, i); + int k = _rng.Next(i + 1); + var temp = list[i]; + list[i] = list[k]; + list[k] = temp; + } + } + private void ReplaceQueueWithList(List list) + { + Queue.Clear(); + foreach (Song song in list) + { + Queue.Add(song); } } public void ToggleShuffle() @@ -122,24 +143,7 @@ public void SetShuffle(ShuffleState newState) private void ShuffleLogic() { - if (CurrentShuffleState == ShuffleState.Shuffle) - { - _nonShuffledQueueBackup = new List(Queue); - ShuffleQueue(); - } - else - { - if (_nonShuffledQueueBackup.Count > 0) - { - Queue.Clear(); - - foreach (var song in _nonShuffledQueueBackup) - { - Queue.Add(song); - } - _nonShuffledQueueBackup.Clear(); - } - } + } private Artist? GetArtist(string name) @@ -584,36 +588,45 @@ public async Task StartQueueFromAlbumSongAsync(Song startingSong) public async Task StartQueueFromSongAsync(Song startingSong, bool favoritesOnly = false) { - List finalQueue = await Task.Run(async () => + if (CurrentShuffleState == ShuffleState.Shuffle) { var allTracks = await GetAllTracksAsync(); - if (favoritesOnly == true) + allTracks.Remove(startingSong); + await StartShuffledQueueAsync(allTracks, startingSong); + } else + { + List finalQueue = await Task.Run(async () => { - var favoritedtracks = new List(); - foreach (Song track in allTracks) + var allTracks = await GetAllTracksAsync(); + if (favoritesOnly == true) { - if (track.Favorited) + var favoritedtracks = new List(); + foreach (Song track in allTracks) { - favoritedtracks.Add(track); + if (track.Favorited) + { + favoritedtracks.Add(track); + } } + allTracks = favoritedtracks; } - allTracks = favoritedtracks; - } - int index = allTracks.FindIndex(s => s == startingSong); + int index = allTracks.FindIndex(s => s == startingSong); - if (index == -1) return new List(); + if (index == -1) return new List(); - int startIndex = index + 1; - if (startIndex < allTracks.Count) - { - int count = allTracks.Count - startIndex; - return allTracks.GetRange(startIndex, count); - } - return new List(); - }); + int startIndex = index + 1; + if (startIndex < allTracks.Count) + { + int count = allTracks.Count - startIndex; + return allTracks.GetRange(startIndex, count); + } + return new List(); + }); - await SetQueueAsync(finalQueue, startingSong); - PlaySong(startingSong); + await SetQueueAsync(finalQueue, startingSong); + PlaySong(startingSong); + } + } public Task SetQueueAsync(List songs, Song startingSong) { From d1f1a1bc076ad81577869bcb524363baaf6f2dbf Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 16:50:03 -0400 Subject: [PATCH 20/44] shuffle logic 1 --- Services/AudioService.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Services/AudioService.cs b/Services/AudioService.cs index 772e91a..b6afd3d 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -96,7 +96,7 @@ private AudioService() private List Database = new List(); public ObservableCollection Queue = new ObservableCollection(); - private List _fullCurrentSongList= new List(); + private List _fullCurrentSongList = new List(); public List History = new List(); public void PlaySongList(List inputSongList, Song startingSong) @@ -143,7 +143,25 @@ public void SetShuffle(ShuffleState newState) private void ShuffleLogic() { - + var songList = new List(_fullCurrentSongList); + if (CurrentShuffleState == ShuffleState.Shuffle) + { + shuffleSongList(songList); + ReplaceQueueWithList(songList); + } + else + { + int index = songList.FindIndex(s => s == CurrentSongPlaying); + + if (index == -1) return; + + int startIndex = index + 1; + if (startIndex < songList.Count) + { + int count = songList.Count - startIndex; + ReplaceQueueWithList(songList.GetRange(startIndex, count)); + } + } } private Artist? GetArtist(string name) From 6f1aec015ccd3fe0938a4b5295514d214d9deecd Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 17:03:43 -0400 Subject: [PATCH 21/44] tweaked NextSong logic --- Services/AudioService.cs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/Services/AudioService.cs b/Services/AudioService.cs index b6afd3d..c8c3b67 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -267,7 +267,7 @@ public void NextSong() } var songToPlay = Queue.FirstOrDefault(); - if (songToPlay != null) + if (songToPlay != null) // there is a song to play next { PlaySong(songToPlay); @@ -284,29 +284,13 @@ public void NextSong() Queue.Remove(songToPlay); }); } - else if (CurrentRepeatState == RepeatState.Repeat) + else if (CurrentRepeatState == RepeatState.Repeat) // there is no song to play next and it repeat is enabled { - var fullPlaylist = new List(History); - if (currentSong != null) - { - fullPlaylist.Add(currentSong); - } - - if (!fullPlaylist.Any()) return; - dispatcherQueue.TryEnqueue(() => { - Queue.Clear(); - History.Clear(); - foreach (var song in fullPlaylist) - { - Queue.Add(song); - } - - if (CurrentShuffleState == ShuffleState.Shuffle) - { - ShuffleQueue(); - } + var list = _fullCurrentSongList; + if (CurrentShuffleState == ShuffleState.Shuffle) shuffleSongList(list); + ReplaceQueueWithList(list); var firstSongInNewQueue = Queue.FirstOrDefault(); if (firstSongInNewQueue != null) From e0ebbf3a4b43340da3f1b88ef0d2e1977a8ba0fe Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 19:13:06 -0400 Subject: [PATCH 22/44] redid play album --- Services/AudioService.cs | 77 ++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/Services/AudioService.cs b/Services/AudioService.cs index c8c3b67..3a1a592 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -537,7 +537,7 @@ private Song ExtractSongData(TagLib.File tfile, string path, Album album) } private bool IsLossless(string path) { - var extension = System.IO.Path.GetExtension(path).ToLower(); + var extension = Path.GetExtension(path).ToLower(); if (!audioExtensions.Contains(extension)) { return false; @@ -566,29 +566,12 @@ public async Task ScanDirectoryIntoLibrary(string targetDirectory) await ScanDirectoryIntoLibrary(subdirectory); } - public async Task StartQueueFromAlbumSongAsync(Song startingSong) - { - List finalQueue = await Task.Run(async () => - { - var albumSongs = startingSong.Album.Songs; - int index = albumSongs.FindIndex(s => s == startingSong); - - if (index == -1) return new List(); - - int startIndex = index + 1; - if (startIndex < albumSongs.Count) - { - int count = albumSongs.Count - startIndex; - return albumSongs.GetRange(startIndex, count); - } - return new List(); - }); - - await SetQueueAsync(finalQueue, startingSong); - PlaySong(startingSong); + public async Task PlayAlbumAsync(Song startingSong) //TODO: remake this + { + PlaySongList(startingSong.Album.Songs, startingSong); } - public async Task StartQueueFromSongAsync(Song startingSong, bool favoritesOnly = false) + public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) //TODO: remake this { if (CurrentShuffleState == ShuffleState.Shuffle) { @@ -630,31 +613,31 @@ public async Task StartQueueFromSongAsync(Song startingSong, bool favoritesOnly } } - public Task SetQueueAsync(List songs, Song startingSong) - { - var tcs = new TaskCompletionSource(); - - dispatcherQueue.TryEnqueue(() => - { - try - { - Queue.Clear(); - _nonShuffledQueueBackup.Clear(); - foreach (var song in songs) - { - Queue.Add(song); - } - tcs.SetResult(); - } - catch (Exception ex) - { - tcs.SetException(ex); - } - }); - - return tcs.Task; - } - public Task StartShuffledQueueAsync(List songs, Song startingSong) + //public Task SetQueueAsync(List songs, Song startingSong) //TODO: remake this + //{ + // var tcs = new TaskCompletionSource(); + + // dispatcherQueue.TryEnqueue(() => + // { + // try + // { + // Queue.Clear(); + // _nonShuffledQueueBackup.Clear(); + // foreach (var song in songs) + // { + // Queue.Add(song); + // } + // tcs.SetResult(); + // } + // catch (Exception ex) + // { + // tcs.SetException(ex); + // } + // }); + + // return tcs.Task; + //} + public Task StartShuffledQueueAsync(List songs, Song startingSong) //TODO: remake this { var tcs = new TaskCompletionSource(); From 4487832cfa6d60eea66c5beb366beb676a870d13 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 19:35:37 -0400 Subject: [PATCH 23/44] album playback with new queue system --- Pages/Favorited.xaml.cs | 2 +- Pages/InnerAlbum.xaml.cs | 4 ++-- Pages/Tracks.xaml.cs | 2 +- Services/AudioService.cs | 46 +++++++++++++++++++++++----------------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Pages/Favorited.xaml.cs b/Pages/Favorited.xaml.cs index b8ac1f4..3574137 100644 --- a/Pages/Favorited.xaml.cs +++ b/Pages/Favorited.xaml.cs @@ -47,7 +47,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - await Audio.StartQueueFromSongAsync(clickedControl.Song, true); + //await Audio.StartQueueFromSongAsync(clickedControl.Song, true); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Pages/InnerAlbum.xaml.cs b/Pages/InnerAlbum.xaml.cs index 39a731f..bfb2a09 100644 --- a/Pages/InnerAlbum.xaml.cs +++ b/Pages/InnerAlbum.xaml.cs @@ -76,7 +76,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - await Audio.StartQueueFromAlbumSongAsync(clickedControl.Song); + Audio.PlayAlbumAsync(clickedControl.Song); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } @@ -90,7 +90,7 @@ private async void PlayButton_Click(object sender, RoutedEventArgs e) if (firstSong == null) return; Audio.SetShuffle(ShuffleState.Off); - await Audio.StartQueueFromAlbumSongAsync(firstSong); + Audio.PlayAlbumAsync(firstSong); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Pages/Tracks.xaml.cs b/Pages/Tracks.xaml.cs index 6716da0..422caf4 100644 --- a/Pages/Tracks.xaml.cs +++ b/Pages/Tracks.xaml.cs @@ -47,7 +47,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - await Audio.StartQueueFromSongAsync(clickedControl.Song); + //await Audio.StartQueueFromSongAsync(clickedControl.Song); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Services/AudioService.cs b/Services/AudioService.cs index 3a1a592..1defd65 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -140,6 +140,19 @@ public void SetShuffle(ShuffleState newState) CurrentShuffleState = newState; ShuffleLogic(); } + private void ReplaceQueueWithCurrentUnshuffled() + { + int index = _fullCurrentSongList.FindIndex(s => s == CurrentSongPlaying); + + if (index == -1) return; + + int startIndex = index + 1; + if (startIndex <= _fullCurrentSongList.Count) + { + int count = _fullCurrentSongList.Count - startIndex; + ReplaceQueueWithList(_fullCurrentSongList.GetRange(startIndex, count)); + } + } private void ShuffleLogic() { @@ -147,20 +160,12 @@ private void ShuffleLogic() if (CurrentShuffleState == ShuffleState.Shuffle) { shuffleSongList(songList); + songList.Remove(CurrentSongPlaying); ReplaceQueueWithList(songList); } else { - int index = songList.FindIndex(s => s == CurrentSongPlaying); - - if (index == -1) return; - - int startIndex = index + 1; - if (startIndex < songList.Count) - { - int count = songList.Count - startIndex; - ReplaceQueueWithList(songList.GetRange(startIndex, count)); - } + ReplaceQueueWithCurrentUnshuffled(); } } @@ -566,9 +571,10 @@ public async Task ScanDirectoryIntoLibrary(string targetDirectory) await ScanDirectoryIntoLibrary(subdirectory); } - public async Task PlayAlbumAsync(Song startingSong) //TODO: remake this - { - PlaySongList(startingSong.Album.Songs, startingSong); + public void PlayAlbumAsync(Song startingSong) //TODO: remake this + { + PlaySongList([.. startingSong.Album.Songs], startingSong); + ReplaceQueueWithCurrentUnshuffled(); } public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) //TODO: remake this @@ -608,7 +614,7 @@ public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) return new List(); }); - await SetQueueAsync(finalQueue, startingSong); + //await SetQueueAsync(finalQueue, startingSong); PlaySong(startingSong); } @@ -645,12 +651,12 @@ public Task StartShuffledQueueAsync(List songs, Song startingSong) //TODO: { try { - _nonShuffledQueueBackup.Clear(); - foreach (var song in songs) - { - _nonShuffledQueueBackup.Add(song); - _nonShuffledQueueBackup.Remove(startingSong); - } + //_nonShuffledQueueBackup.Clear(); + //foreach (var song in songs) + //{ + // _nonShuffledQueueBackup.Add(song); + // _nonShuffledQueueBackup.Remove(startingSong); + //} Queue.Clear(); var songsToShuffle = songs.Where(s => s != startingSong); From 91cb8a62beac8b1000b1eb60c7d023a55bfbe58a Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 19:36:40 -0400 Subject: [PATCH 24/44] forgot to make this only for main, don't want to waste minutes lol! --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index baeded2..52a9f98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,11 +4,9 @@ on: push: branches: - main - - dev pull_request: branches: - main - - dev jobs: From d9773d39fbcc8f5c4c3bcb08c4334b51f5305e4a Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 19:53:12 -0400 Subject: [PATCH 25/44] added to tracks/favorites --- Pages/Favorited.xaml.cs | 2 +- Pages/InnerAlbum.xaml.cs | 4 +- Pages/Tracks.xaml.cs | 2 +- Services/AudioService.cs | 85 ++++++---------------------------------- 4 files changed, 16 insertions(+), 77 deletions(-) diff --git a/Pages/Favorited.xaml.cs b/Pages/Favorited.xaml.cs index 3574137..99b4892 100644 --- a/Pages/Favorited.xaml.cs +++ b/Pages/Favorited.xaml.cs @@ -47,7 +47,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - //await Audio.StartQueueFromSongAsync(clickedControl.Song, true); + await Audio.PlayTrackAsync(clickedControl.Song, true); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Pages/InnerAlbum.xaml.cs b/Pages/InnerAlbum.xaml.cs index bfb2a09..f9bc88a 100644 --- a/Pages/InnerAlbum.xaml.cs +++ b/Pages/InnerAlbum.xaml.cs @@ -105,8 +105,8 @@ private async void ShuffleButton_Click(object sender, RoutedEventArgs e) var firstSong = songs.ElementAtOrDefault(randomIndex); if (firstSong == null) return; - await Audio.StartShuffledQueueAsync(songs, firstSong); - + Audio.PlayAlbumAsync(firstSong); + Audio.SetShuffle(ShuffleState.Shuffle); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Pages/Tracks.xaml.cs b/Pages/Tracks.xaml.cs index 422caf4..29c60b3 100644 --- a/Pages/Tracks.xaml.cs +++ b/Pages/Tracks.xaml.cs @@ -47,7 +47,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - //await Audio.StartQueueFromSongAsync(clickedControl.Song); + await Audio.PlayTrackAsync(clickedControl.Song, false); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } diff --git a/Services/AudioService.cs b/Services/AudioService.cs index 1defd65..4dfa35a 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -571,53 +571,29 @@ public async Task ScanDirectoryIntoLibrary(string targetDirectory) await ScanDirectoryIntoLibrary(subdirectory); } - public void PlayAlbumAsync(Song startingSong) //TODO: remake this + public void PlayAlbumAsync(Song startingSong) { PlaySongList([.. startingSong.Album.Songs], startingSong); + if (CurrentShuffleState == ShuffleState.Shuffle) return; ReplaceQueueWithCurrentUnshuffled(); } - public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) //TODO: remake this + public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) { - if (CurrentShuffleState == ShuffleState.Shuffle) - { - var allTracks = await GetAllTracksAsync(); - allTracks.Remove(startingSong); - await StartShuffledQueueAsync(allTracks, startingSong); - } else + var tracks = await GetAllTracksAsync(); + if (favoritesOnly) { - List finalQueue = await Task.Run(async () => + foreach (Song song in tracks) { - var allTracks = await GetAllTracksAsync(); - if (favoritesOnly == true) - { - var favoritedtracks = new List(); - foreach (Song track in allTracks) - { - if (track.Favorited) - { - favoritedtracks.Add(track); - } - } - allTracks = favoritedtracks; - } - int index = allTracks.FindIndex(s => s == startingSong); - - if (index == -1) return new List(); - - int startIndex = index + 1; - if (startIndex < allTracks.Count) + if (song.Favorited == false) { - int count = allTracks.Count - startIndex; - return allTracks.GetRange(startIndex, count); + tracks.Remove(song); } - return new List(); - }); - - //await SetQueueAsync(finalQueue, startingSong); - PlaySong(startingSong); + } } - + PlaySongList(tracks, startingSong); + if (CurrentShuffleState == ShuffleState.Shuffle) return; + ReplaceQueueWithCurrentUnshuffled(); } //public Task SetQueueAsync(List songs, Song startingSong) //TODO: remake this //{ @@ -643,43 +619,6 @@ public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) // return tcs.Task; //} - public Task StartShuffledQueueAsync(List songs, Song startingSong) //TODO: remake this - { - var tcs = new TaskCompletionSource(); - - dispatcherQueue.TryEnqueue(() => - { - try - { - //_nonShuffledQueueBackup.Clear(); - //foreach (var song in songs) - //{ - // _nonShuffledQueueBackup.Add(song); - // _nonShuffledQueueBackup.Remove(startingSong); - //} - - Queue.Clear(); - var songsToShuffle = songs.Where(s => s != startingSong); - var shuffledQueue = songsToShuffle.OrderBy(s => _rng.Next()); - foreach (var song in shuffledQueue) - { - Queue.Add(song); - } - - PlaySong(startingSong); - - CurrentShuffleState = ShuffleState.Shuffle; - - tcs.SetResult(); - } - catch (Exception ex) - { - tcs.SetException(ex); - } - }); - - return tcs.Task; - } public static async Task ResizeImageAsync(byte[] imageData, uint newWidth) { var inputStream = new InMemoryRandomAccessStream(); From 1b667b77454eac661ece44514aa2359d3e281a1c Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 20:05:52 -0400 Subject: [PATCH 26/44] fixed favorite tracks being broken, renamed PlayAlbumAsync to PlayAlbum, as async is no longer needed --- Pages/InnerAlbum.xaml.cs | 6 +++--- Services/AudioService.cs | 10 ++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Pages/InnerAlbum.xaml.cs b/Pages/InnerAlbum.xaml.cs index f9bc88a..24400f2 100644 --- a/Pages/InnerAlbum.xaml.cs +++ b/Pages/InnerAlbum.xaml.cs @@ -76,7 +76,7 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) var clickedControl = sender as TrackItemControl; if (clickedControl != null) { - Audio.PlayAlbumAsync(clickedControl.Song); + Audio.PlayAlbum(clickedControl.Song); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } @@ -90,7 +90,7 @@ private async void PlayButton_Click(object sender, RoutedEventArgs e) if (firstSong == null) return; Audio.SetShuffle(ShuffleState.Off); - Audio.PlayAlbumAsync(firstSong); + Audio.PlayAlbum(firstSong); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } @@ -105,7 +105,7 @@ private async void ShuffleButton_Click(object sender, RoutedEventArgs e) var firstSong = songs.ElementAtOrDefault(randomIndex); if (firstSong == null) return; - Audio.PlayAlbumAsync(firstSong); + Audio.PlayAlbum(firstSong); Audio.SetShuffle(ShuffleState.Shuffle); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); diff --git a/Services/AudioService.cs b/Services/AudioService.cs index 4dfa35a..b26d1c3 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -571,7 +571,7 @@ public async Task ScanDirectoryIntoLibrary(string targetDirectory) await ScanDirectoryIntoLibrary(subdirectory); } - public void PlayAlbumAsync(Song startingSong) + public void PlayAlbum(Song startingSong) { PlaySongList([.. startingSong.Album.Songs], startingSong); if (CurrentShuffleState == ShuffleState.Shuffle) return; @@ -583,13 +583,7 @@ public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) var tracks = await GetAllTracksAsync(); if (favoritesOnly) { - foreach (Song song in tracks) - { - if (song.Favorited == false) - { - tracks.Remove(song); - } - } + tracks = tracks.Where(song => song.Favorited).ToList(); } PlaySongList(tracks, startingSong); if (CurrentShuffleState == ShuffleState.Shuffle) return; From d3accce36ba83a915b27233c0c5e258f51d1b4bf Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 20:12:03 -0400 Subject: [PATCH 27/44] version bump! --- Pages/SettingsPage.xaml | 2 +- Services/AudioService.cs | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/Pages/SettingsPage.xaml b/Pages/SettingsPage.xaml index c5e123b..5d06fd6 100644 --- a/Pages/SettingsPage.xaml +++ b/Pages/SettingsPage.xaml @@ -50,7 +50,7 @@ - + diff --git a/Services/AudioService.cs b/Services/AudioService.cs index b26d1c3..8829fd4 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -589,30 +589,6 @@ public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) if (CurrentShuffleState == ShuffleState.Shuffle) return; ReplaceQueueWithCurrentUnshuffled(); } - //public Task SetQueueAsync(List songs, Song startingSong) //TODO: remake this - //{ - // var tcs = new TaskCompletionSource(); - - // dispatcherQueue.TryEnqueue(() => - // { - // try - // { - // Queue.Clear(); - // _nonShuffledQueueBackup.Clear(); - // foreach (var song in songs) - // { - // Queue.Add(song); - // } - // tcs.SetResult(); - // } - // catch (Exception ex) - // { - // tcs.SetException(ex); - // } - // }); - - // return tcs.Task; - //} public static async Task ResizeImageAsync(byte[] imageData, uint newWidth) { var inputStream = new InMemoryRandomAccessStream(); From 36442c74c6881f96b2093eb255618a95a0fda3c7 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 20:24:56 -0400 Subject: [PATCH 28/44] changed some icons, renamed favorites, began work on context menu --- Controls/TrackItemControl.xaml | 10 +++++++++- Controls/TrackItemControl.xaml.cs | 5 +++++ MainWindow.xaml | 8 ++++---- Musium.csproj | 3 +-- Pages/{Favorited.xaml => Favorites.xaml} | 4 ++-- Pages/{Favorited.xaml.cs => Favorites.xaml.cs} | 14 +++++++------- 6 files changed, 28 insertions(+), 16 deletions(-) rename Pages/{Favorited.xaml => Favorites.xaml} (94%) rename Pages/{Favorited.xaml.cs => Favorites.xaml.cs} (77%) diff --git a/Controls/TrackItemControl.xaml b/Controls/TrackItemControl.xaml index 414f83c..b7ab060 100644 --- a/Controls/TrackItemControl.xaml +++ b/Controls/TrackItemControl.xaml @@ -15,6 +15,13 @@ + + + + + + + + + + AllFavoriteTracks { get; } = new ObservableCollection(); + + private readonly Random _rng = new Random(); public Favorites() { InitializeComponent(); @@ -52,5 +54,27 @@ private async void TrackItemControl_Clicked(object sender, RoutedEventArgs e) MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } } + + private async void PlayButton_Click(object sender, RoutedEventArgs e) + { + var firstSong = AllFavoriteTracks.FirstOrDefault(); + if (firstSong == null) return; + await Audio.PlayTrackAsync(firstSong, true); + Audio.SetShuffle(ShuffleState.Off); + Frame.Navigate(typeof(NowPlaying)); + MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); + } + + private async void ShuffleButton_Click(object sender, RoutedEventArgs e) + { + var randomIndex = _rng.Next(AllFavoriteTracks.Count); + var firstSong = AllFavoriteTracks.ElementAtOrDefault(randomIndex); + if (firstSong == null) return; + + await Audio.PlayTrackAsync(firstSong, true); + Audio.SetShuffle(ShuffleState.Shuffle); + Frame.Navigate(typeof(NowPlaying)); + MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); + } } } From 9c67184421a148df656d030b962f54a013d483f9 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 21:51:43 -0400 Subject: [PATCH 31/44] fixed bug where pressing Play with shuffle enabled still shuffled --- Pages/InnerAlbum.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pages/InnerAlbum.xaml.cs b/Pages/InnerAlbum.xaml.cs index 24400f2..5b9634a 100644 --- a/Pages/InnerAlbum.xaml.cs +++ b/Pages/InnerAlbum.xaml.cs @@ -89,8 +89,8 @@ private async void PlayButton_Click(object sender, RoutedEventArgs e) var firstSong = Audio.CurrentViewedAlbum.Songs.FirstOrDefault(); if (firstSong == null) return; - Audio.SetShuffle(ShuffleState.Off); Audio.PlayAlbum(firstSong); + Audio.SetShuffle(ShuffleState.Off); Frame.Navigate(typeof(NowPlaying)); MainWindow.UpdateNavigationViewSelection(typeof(NowPlaying)); } From 6e618308ff7054bb273fe73717deff444bc3b2e7 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 21:51:49 -0400 Subject: [PATCH 32/44] new icon for Tracks --- MainWindow.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MainWindow.xaml b/MainWindow.xaml index d0c496b..55c0c25 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -66,7 +66,7 @@ Content="Tracks" Tag="Musium.Pages.Tracks"> - + From 5d6ba439303c353f7c5f7921eab6667b7d292ef1 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 22:00:16 -0400 Subject: [PATCH 33/44] changed naming added functions --- Controls/TrackItemControl.xaml | 6 +++--- Controls/TrackItemControl.xaml.cs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Controls/TrackItemControl.xaml b/Controls/TrackItemControl.xaml index c689992..c385050 100644 --- a/Controls/TrackItemControl.xaml +++ b/Controls/TrackItemControl.xaml @@ -16,17 +16,17 @@ - + - + - + diff --git a/Controls/TrackItemControl.xaml.cs b/Controls/TrackItemControl.xaml.cs index 8f826d1..638ad30 100644 --- a/Controls/TrackItemControl.xaml.cs +++ b/Controls/TrackItemControl.xaml.cs @@ -98,7 +98,11 @@ private void Favorite_Click(object sender, RoutedEventArgs e) Song.Favorited = !Song.Favorited; } - private void Button_RightTapped(object sender, RightTappedRoutedEventArgs e) + private void NextQueue_Click(object sender, RoutedEventArgs e) + { + + } + private void LastQueue_Click(object sender, RoutedEventArgs e) { } From 272710c508f511a7f89a0b8763bd57a2ef9d460c Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 22:03:40 -0400 Subject: [PATCH 34/44] added context menu functionality --- Controls/TrackItemControl.xaml.cs | 9 ++++++--- Services/AudioService.cs | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Controls/TrackItemControl.xaml.cs b/Controls/TrackItemControl.xaml.cs index 638ad30..a45ae55 100644 --- a/Controls/TrackItemControl.xaml.cs +++ b/Controls/TrackItemControl.xaml.cs @@ -1,4 +1,3 @@ -using Musium.Models; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; @@ -7,6 +6,8 @@ using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Media.Imaging; using Microsoft.UI.Xaml.Navigation; +using Musium.Models; +using Musium.Services; using System; using System.Collections.Generic; using System.ComponentModel; @@ -31,6 +32,8 @@ void OnPropertyChanged([CallerMemberName] string? name = null) PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } + public readonly AudioService Audio = AudioService.Instance; + private BitmapImage? _displayedCoverArt; public BitmapImage? DisplayedCoverArt { @@ -100,10 +103,10 @@ private void Favorite_Click(object sender, RoutedEventArgs e) private void NextQueue_Click(object sender, RoutedEventArgs e) { - + Audio.InsertStartOfQueue(Song); } private void LastQueue_Click(object sender, RoutedEventArgs e) { - + Audio.InsertEndOfQueue(Song); } } diff --git a/Services/AudioService.cs b/Services/AudioService.cs index 8829fd4..f9241e4 100644 --- a/Services/AudioService.cs +++ b/Services/AudioService.cs @@ -589,6 +589,15 @@ public async Task PlayTrackAsync(Song startingSong, bool favoritesOnly = false) if (CurrentShuffleState == ShuffleState.Shuffle) return; ReplaceQueueWithCurrentUnshuffled(); } + + public void InsertStartOfQueue(Song song) + { + Queue.Insert(0, song); + } + public void InsertEndOfQueue(Song song) + { + Queue.Add(song); + } public static async Task ResizeImageAsync(byte[] imageData, uint newWidth) { var inputStream = new InMemoryRandomAccessStream(); From c50276d7059a4af8b7e9d52439ae2b7357a0cd27 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 22:10:19 -0400 Subject: [PATCH 35/44] added removing from queue in Audio service, binded context menu favorite icon to favorite status --- Controls/TrackItemControl.xaml | 40 +++++++++++++++++----------------- Services/AudioService.cs | 4 ++++ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Controls/TrackItemControl.xaml b/Controls/TrackItemControl.xaml index c385050..5c04de2 100644 --- a/Controls/TrackItemControl.xaml +++ b/Controls/TrackItemControl.xaml @@ -15,23 +15,6 @@ - - - - - - - - - - - - - - - - - - + + + + diff --git a/Pages/NowPlaying.xaml b/Pages/NowPlaying.xaml index d370c03..98c6d03 100644 --- a/Pages/NowPlaying.xaml +++ b/Pages/NowPlaying.xaml @@ -104,7 +104,7 @@ From 02182420d538bf2311fec1bdc90845ee039acfa0 Mon Sep 17 00:00:00 2001 From: jamied Date: Tue, 30 Sep 2025 23:56:42 -0400 Subject: [PATCH 37/44] awaiting favorite added to song --- Controls/TrackItemControl.xaml | 2 +- Controls/TrackItemControl.xaml.cs | 5 +++++ Models/Song.cs | 22 +++++++++++++++++++++- Pages/Favorites.xaml | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Controls/TrackItemControl.xaml b/Controls/TrackItemControl.xaml index dc2bd17..c4eb120 100644 --- a/Controls/TrackItemControl.xaml +++ b/Controls/TrackItemControl.xaml @@ -36,7 +36,7 @@ - + diff --git a/Controls/TrackItemControl.xaml.cs b/Controls/TrackItemControl.xaml.cs index a45ae55..4439e50 100644 --- a/Controls/TrackItemControl.xaml.cs +++ b/Controls/TrackItemControl.xaml.cs @@ -109,4 +109,9 @@ private void LastQueue_Click(object sender, RoutedEventArgs e) { Audio.InsertEndOfQueue(Song); } + + private void MenuFlyoutItemFav_Click(object sender, RoutedEventArgs e) + { + Song.Favorited = !Song.Favorited; + } } diff --git a/Models/Song.cs b/Models/Song.cs index 9570718..cd6b6c2 100644 --- a/Models/Song.cs +++ b/Models/Song.cs @@ -1,15 +1,27 @@ using Microsoft.UI.Xaml.Media.Imaging; +using Musium.Services; using System; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using Windows.Devices.Radios; +using Windows.Media.Core; namespace Musium.Models { public class Song : ObservableObject { + public readonly AudioService Audio = AudioService.Instance; + public enum AwaitingFavorite + { + Favorite, + Unfavorite, + None + } + + private string _title; public string Title { @@ -64,7 +76,7 @@ public int? TrackNumber OnPropertyChanged(); } } - + public AwaitingFavorite CurrentlyAwaitingFavorite = AwaitingFavorite.None; private bool? _favorited; public bool Favorited { @@ -74,9 +86,17 @@ public bool Favorited bool isInitialSet = !_favorited.HasValue; if (_favorited == value) return; + if (Audio.CurrentSongPlaying == this) + { + CurrentlyAwaitingFavorite = value ? AwaitingFavorite.Favorite : AwaitingFavorite.Unfavorite; + return; + } + _favorited = value; OnPropertyChanged(); + + if (isInitialSet) return; using (var file = TagLib.File.Create(FilePath)) { diff --git a/Pages/Favorites.xaml b/Pages/Favorites.xaml index 878149f..f349d05 100644 --- a/Pages/Favorites.xaml +++ b/Pages/Favorites.xaml @@ -29,7 +29,7 @@ ItemContainerStyle="{StaticResource NakedListViewItemStyle}" Padding="16"> - + diff --git a/Converters/BoolToAccentBrushConverter.cs b/Converters/BoolToAccentBrushConverter.cs new file mode 100644 index 0000000..cd0b52c --- /dev/null +++ b/Converters/BoolToAccentBrushConverter.cs @@ -0,0 +1,33 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Media; +using Musium.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.UI; + +namespace Musium.Converters +{ + public class BoolToAccentBrushConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + if (value is bool state && state == true) + { + return Application.Current.Resources["AccentFillColorDefaultBrush"] as SolidColorBrush; + } + else + { + return Application.Current.Resources["TextFillColorPrimaryBrush"] as SolidColorBrush; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/Converters/RepeatStateToBrushConverter.cs b/Converters/RepeatStateToBrushConverter.cs index 50efb66..d676202 100644 --- a/Converters/RepeatStateToBrushConverter.cs +++ b/Converters/RepeatStateToBrushConverter.cs @@ -17,8 +17,7 @@ public object Convert(object value, Type targetType, object parameter, string la { if (value is RepeatState state && state != RepeatState.Off) { - var accentColor = (Color)Application.Current.Resources["SystemAccentColor"]; - return new SolidColorBrush(accentColor); + return Application.Current.Resources["AccentFillColorDefaultBrush"] as SolidColorBrush; } else { diff --git a/Converters/ShuffleStateToBrushConverter.cs b/Converters/ShuffleStateToBrushConverter.cs index 6e73e44..4b98311 100644 --- a/Converters/ShuffleStateToBrushConverter.cs +++ b/Converters/ShuffleStateToBrushConverter.cs @@ -17,8 +17,7 @@ public object Convert(object value, Type targetType, object parameter, string la { if (value is ShuffleState state && state == ShuffleState.Shuffle) { - var accentColor = (Color)Application.Current.Resources["SystemAccentColor"]; - return new SolidColorBrush(accentColor); + return Application.Current.Resources["AccentFillColorDefaultBrush"] as SolidColorBrush; } else { diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index adb72b1..813d8b3 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -43,7 +43,7 @@ public MainWindow() ExtendsContentIntoTitleBar = true; SetTitleBar(Titlebar); - UpdateNavigationViewSelection(typeof(Musium.Pages.Albums)); + UpdateNavigationViewSelection(typeof(Musium.Pages.NowPlaying)); Audio.SetDispatcherQueue(DispatcherQueue); Audio.SetMediaPlayer(AudioPlayerElement); diff --git a/Pages/NowPlaying.xaml.cs b/Pages/NowPlaying.xaml.cs index 0f85ab2..ddaa08a 100644 --- a/Pages/NowPlaying.xaml.cs +++ b/Pages/NowPlaying.xaml.cs @@ -118,6 +118,7 @@ private void Audio_PropertyChanged(object sender, PropertyChangedEventArgs e) } private void Audio_PositionChanged(object sender, TimeSpan newPos) { + if (DispatcherQueue == null) return; DispatcherQueue.TryEnqueue(() => { TimeElapsed.Text = $"{newPos:m\\:ss}";