Skip to content

Commit

Permalink
Prevent episode from being played resolves #17 and resolves #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
dyerc committed May 24, 2019
1 parent 139d9c3 commit fe188c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Doughnut.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\"";
shellScript = "buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"${PROJECT_DIR}/${INFOPLIST_FILE}\"\n";
};
A3819D0A54A45BF19A833E00 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion Doughnut/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<key>CFBundleVersion</key>
<string>48</string>
<string>53</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
Expand Down
13 changes: 9 additions & 4 deletions Doughnut/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ class Player: NSObject {
guard let podcast = episode.podcast else { return }

// Destroy any existing player
if let avPlayer = avPlayer, let current = currentEpisode {
if current.id != episode.id {
avPlayer.pause()
self.avPlayer = nil
if let avPlayer = avPlayer {
if let existing = currentEpisode, existing.id == episode.id {
// This episode is already playing so just ignore and abort play()
return
}

// Destroy the existing player and let a new one be created
avPlayer.pause()
self.avPlayer = nil
}

if episode.downloaded {
Expand Down Expand Up @@ -148,6 +152,7 @@ class Player: NSObject {

avPlayer.volume = volume
delegate?.update(forEpisode: episode)
currentEpisode = episode
avPlayer.play()
}
}
Expand Down

0 comments on commit fe188c1

Please sign in to comment.