Skip to content

Commit

Permalink
update toolbar properly on seek when paused
Browse files Browse the repository at this point in the history
  • Loading branch information
NattyNarwhal committed Jul 5, 2024
1 parent 42668bc commit e554012
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Submariner/SBDatabaseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ - (id)initWithManagedObjectContext:(NSManagedObjectContext *)context {

- (void)dealloc
{
// remove player observer
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"SBPlaySeekNotification" object:nil];
// remove window observer
[self.window.contentView removeObserver: self forKeyPath: @"safeAreaInsets"];
// remove Subsonic observers
Expand Down Expand Up @@ -276,6 +278,12 @@ - (void)windowDidLoad {
selector:@selector(updateMenuBindings:)
name:@"SBFirstResponderNoLonger"
object:nil];

// update the seek progress
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerSeekNotification:)
name:@"SBPlaySeekNotification"
object:nil];


// setup main box subviews animation
Expand Down Expand Up @@ -1481,6 +1489,12 @@ - (void)playerPlayStateNotification:(NSNotification *)notification {
}
}

- (void)playerSeekNotification:(NSNotification*)notification {
// we get this from seek dialog, NPIC seeks, toolbar seeks
// note that dragging the toolbar slider does not constantly send notifications
[self updateProgress];
}

- (void)playerHaveMovieToPlayNotification:(NSNotification *)notification {
// We get this on playlist update but in theory, we could get it for specific media in the future
//[self displayViewControllerForResource:[notification object]];
Expand Down
3 changes: 3 additions & 0 deletions Submariner/SBPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fileprivate let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, catego

extension NSNotification.Name {
static let SBPlayerPlaylistUpdated = NSNotification.Name("SBPlayerPlaylistUpdatedNotification")
static let SBPlaySeekNotification = NSNotification.Name("SBPlaySeekNotification")
static let SBPlayerPlayState = NSNotification.Name("SBPlayerPlayStateNotification")
}

Expand Down Expand Up @@ -714,6 +715,7 @@ extension NSNotification.Name {

// seeks will desync the NPIC
updateSystemNowPlayingStatus()
NotificationCenter.default.post(name: .SBPlaySeekNotification, object: self)
}

@objc(seek:) func seek(percentage: Double) {
Expand All @@ -725,6 +727,7 @@ extension NSNotification.Name {

// seeks will desync the NPIC
updateSystemNowPlayingStatus()
NotificationCenter.default.post(name: .SBPlaySeekNotification, object: self)
}

@objc(relativeSeekBy:) func relativeSeekBy(increment: Float) {
Expand Down

0 comments on commit e554012

Please sign in to comment.