Skip to content

Commit

Permalink
Better handling of video splash
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpynov committed May 27, 2024
1 parent 819563c commit 9c06920
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
5 changes: 3 additions & 2 deletions MediaElementsMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static public void Attach(IPlayniteAPI api, PlayniteSoundsSettings settings)
EventManager.RegisterClassHandler(typeof(MediaElement), MediaElement.MediaOpenedEvent, new RoutedEventHandler(MediaElement_Opened));

timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromTicks(100);
timer.Interval = TimeSpan.FromMilliseconds(10);
timer.Tick += Timer_Tick;
}

Expand All @@ -73,7 +73,6 @@ public static List<MediaElement> GetAllMediaElements(DependencyObject parent)
}
static private void Timer_Tick(object sender, EventArgs e)
{

bool someIsPlaying = false;
var mediaElements = GetAllMediaElements(Application.Current.MainWindow);

Expand Down Expand Up @@ -120,11 +119,13 @@ static private void Timer_Tick(object sender, EventArgs e)
if (mediaElementPositions.Count == 0)
{
timer.Stop();
settings.VideoIsPlaying = false;
}
}

static private void MediaElement_Opened(object sender, RoutedEventArgs e)
{
Timer_Tick(sender, e);
timer.Start();
}
}
Expand Down
20 changes: 13 additions & 7 deletions PlayniteSounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ public PlayniteSounds(IPlayniteAPI api) : base(api)
{
SourceName = "Sounds",
SettingsRoot = $"{nameof(SettingsModel)}.{nameof(SettingsModel.Settings)}"
});
});
if (SettingsModel.Settings.PauseOnTrailer)
MediaElementsMonitor.Attach(PlayniteApi, SettingsModel.Settings);

}
catch (Exception e)
Expand Down Expand Up @@ -266,9 +268,6 @@ public override void OnApplicationStarted(OnApplicationStartedEventArgs args)
Application.Current.MainWindow.StateChanged += OnWindowStateChanged;
Application.Current.Deactivated += OnApplicationDeactivate;
Application.Current.Activated += OnApplicationActivate;

if (SettingsModel.Settings.PauseOnTrailer)
MediaElementsMonitor.Attach(PlayniteApi, SettingsModel.Settings);
}

public override void OnApplicationStopped(OnApplicationStoppedEventArgs args)
Expand Down Expand Up @@ -598,9 +597,16 @@ private void PlayMusicFromFiles(string[] musicFiles)

private void ResumeMusic()
{
if (ShouldPlayMusic() && _musicPlayer.Clock != null)
{
Try(_musicPlayer.Clock.Controller.Resume);
if (ShouldPlayMusic())
{
if (_musicPlayer.Clock != null)
{
Try(_musicPlayer.Clock.Controller.Resume);
}
else
{
PlayMusicBasedOnSelected();
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions PlayniteSounds.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
AddonId: 'Playnite.Sounds.Mod.baf1744c-72f6-4bc1-92cc-474403b279fb'
Packages:
- Version: 5.7.4
RequiredApiVersion: 6.11.0
ReleaseDate: 2024-05-27
PackageUrl: https://github.com/ashpynov/PlayniteSound/releases/download/v5.7.4/Playnite.Sounds.Mod.baf1744c-72f6-4bc1-92cc-474403b279fb_5_7_4.pext
Changelog:
- Better handling startup splash video
- Reduced monitoring workload and better keeping music muted
- Version: 5.7.3
RequiredApiVersion: 6.11.0
ReleaseDate: 2024-05-23
Expand Down
6 changes: 5 additions & 1 deletion extension.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Id: Playnite.Sounds.Mod.baf1744c-72f6-4bc1-92cc-474403b279fb
Name: Playnite Sounds Mod
Author: ashpynov, cnapolit, Joyrider3774
Version: 5.7.3
Version: 5.7.4
Module: PlayniteSounds.dll
Type: GenericPlugin
Icon: icon.png
Expand All @@ -14,3 +14,7 @@ Links:
Url: https://discord.com/channels/365863063296933888/808419165311467630
- Name: Bug tracker
Url: https://github.com/ashpynov/PlayniteSound/issues
- Name: Ko-fi for Tips
Url: https://ko-fi.com/ashpynov
- Name: Boosty for Tips
Url: https://boosty.to/ashpynov/donate

0 comments on commit 9c06920

Please sign in to comment.