Skip to content

Commit

Permalink
Fix CloseAudioFiles Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joyrider3774 committed Apr 30, 2021
1 parent 215fb59 commit 58b2c37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions PlayniteSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,28 +449,31 @@ public void CloseAudioFiles()
foreach (string keyname in players.Keys)
{
PlayerEntry Entry = players[keyname];
if (Entry.TypePlayer == 1)
if (Entry.FileExists)
{
string filename = Entry.MediaPlayer.Source.LocalPath;
Entry.MediaPlayer.Stop();
Entry.MediaPlayer.Close();
Entry.MediaPlayer = null;
if (File.Exists(filename))
if (Entry.TypePlayer == 1)
{
int count = 0;
while (IsFileLocked(new FileInfo(filename)))
string filename = Entry.MediaPlayer.Source.LocalPath;
Entry.MediaPlayer.Stop();
Entry.MediaPlayer.Close();
Entry.MediaPlayer = null;
if (File.Exists(filename))
{
Thread.Sleep(5);
count += 5;
if (count > 500)
break;
int count = 0;
while (IsFileLocked(new FileInfo(filename)))
{
Thread.Sleep(5);
count += 5;
if (count > 500)
break;
}
}
}
}
else
{
Entry.SoundPlayer.Stop();
Entry.SoundPlayer = null;
else
{
Entry.SoundPlayer.Stop();
Entry.SoundPlayer = null;
}
}
}
players.Clear();
Expand Down
2 changes: 1 addition & 1 deletion extension.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Id: Playnite.Sounds.WD
Name: Playnite Sounds
Author: Joyrider3774
Version: 3.0
Version: 3.1
Module: PlayniteSounds.dll
Type: GenericPlugin
Icon: icon.png
Expand Down

0 comments on commit 58b2c37

Please sign in to comment.