Skip to content

Commit

Permalink
Version bump to v1.7.1
Browse files Browse the repository at this point in the history
This commit attempts to fix a bug where the Now Playing controls sometimes reach the wrong window
  • Loading branch information
SamusAranX committed Oct 4, 2018
1 parent 34d26b9 commit 495a17d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
Binary file not shown.
10 changes: 7 additions & 3 deletions MinimalMIDIPlayer/DocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,8 @@ class DocumentViewController: NSViewController, WindowControllerDelegate, PWMIDI
}
}

func playbackStarted(firstTime: Bool) {
Swift.print("Playback started from the beginning: \(firstTime)")
self.playPauseButton.state = .on
func playbackWillStart(firstTime: Bool) {
Swift.print("Playback will start from the beginning: \(firstTime)")

guard let thisWindow = self.view.window else {
// this should never fail, but I'm not messing with forced unwraps
Expand All @@ -389,6 +388,11 @@ class DocumentViewController: NSViewController, WindowControllerDelegate, PWMIDI
}
}
}
}

func playbackStarted(firstTime: Bool) {
Swift.print("Playback started from the beginning: \(firstTime)")
self.playPauseButton.state = .on

if #available(OSX 10.12.2, *) {
NowPlayingCentral.shared.playbackState = .playing
Expand Down
4 changes: 2 additions & 2 deletions MinimalMIDIPlayer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.7</string>
<string>1.7.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>192</string>
<string>198</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion MinimalMIDIPlayer/NowPlayingCentral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NowPlayingCentral: NSObject {

func resetNowPlayingInfo() {
MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
self.playbackState = .stopped
self.playbackState = .unknown
}

func initNowPlayingInfo(for midiPlayer: PWMIDIPlayer) {
Expand Down
13 changes: 8 additions & 5 deletions MinimalMIDIPlayer/PWMIDIPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import MediaPlayer
protocol PWMIDIPlayerDelegate: class {

func filesLoaded(midi: URL, soundFont: URL?)


func playbackWillStart(firstTime: Bool)
func playbackStarted(firstTime: Bool)

func playbackPositionChanged(position: TimeInterval, duration: TimeInterval)
Expand Down Expand Up @@ -132,6 +133,8 @@ class PWMIDIPlayer: AVMIDIPlayer {
}

override func play(_ completionHandler: AVMIDIPlayerCompletionHandler? = nil) {
self.delegate?.playbackWillStart(firstTime: self.currentPosition == 0)

super.play() {
DispatchQueue.main.async {
if (self.currentPosition >= self.duration - 0.1) {
Expand All @@ -151,10 +154,10 @@ class PWMIDIPlayer: AVMIDIPlayer {
self.progressTimer!.tolerance = 0.125 / 8

if #available(OSX 10.12.2, *), !Settings.shared.cacophonyMode {
NowPlayingCentral.shared.resetNowPlayingInfo()
NowPlayingCentral.shared.makeActive(player: self)
NowPlayingCentral.shared.initNowPlayingInfo(for: self)
NowPlayingCentral.shared.playbackState = .playing
NowPlayingCentral.shared.resetNowPlayingInfo()
NowPlayingCentral.shared.makeActive(player: self)
NowPlayingCentral.shared.initNowPlayingInfo(for: self)
NowPlayingCentral.shared.playbackState = .playing
}

self.delegate?.playbackStarted(firstTime: self.currentPosition == 0)
Expand Down
2 changes: 1 addition & 1 deletion MinimalMIDIQL/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>392</string>
<string>399</string>
<key>CFPlugInDynamicRegisterFunction</key>
<string></string>
<key>CFPlugInDynamicRegistration</key>
Expand Down

0 comments on commit 495a17d

Please sign in to comment.