From 2f8e30accb304e7ead166210b074352ce57c23b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Kr=C3=A4mer?= Date: Mon, 18 Apr 2022 12:11:29 +0200 Subject: [PATCH] Fixed closePlayback --- components/app/AudioPlayer.vue | 6 ++---- ios/App/App.xcodeproj/project.pbxproj | 4 ++-- ios/App/App/plugins/AbsAudioPlayer.swift | 2 ++ ios/App/Podfile | 14 +++++++------- ios/App/Shared/player/AudioPlayer.swift | 6 ++---- ios/App/Shared/util/NowPlayingInfo.swift | 1 + 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index d7508997..8c20829a 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -498,10 +498,6 @@ export default { resetStream(startTime) { this.closePlayback() }, - closePlayback() { - if (!this.playbackSession) return - AbsAudioPlayer.closePlayback() - }, handleGesture() { var touchDistance = this.touchEndY - this.touchStartY if (touchDistance > 100) { @@ -553,6 +549,8 @@ export default { this.showFullscreen = false this.isEnded = false this.playbackSession = null + + AbsAudioPlayer.closePlayback() }, // // Listeners from audio AbsAudioPlayer diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 5b55446c..6df6f170 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -462,7 +462,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 0.9.40; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; - PRODUCT_BUNDLE_IDENTIFIER = com.audiobookshelf.app.dev; + PRODUCT_BUNDLE_IDENTIFIER = com.audiobookshelf.app.development; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = "App/App-Bridging-Header.h"; @@ -485,7 +485,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 0.9.40; - PRODUCT_BUNDLE_IDENTIFIER = com.audiobookshelf.app.dev; + PRODUCT_BUNDLE_IDENTIFIER = com.audiobookshelf.app; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_OBJC_BRIDGING_HEADER = "App/App-Bridging-Header.h"; diff --git a/ios/App/App/plugins/AbsAudioPlayer.swift b/ios/App/App/plugins/AbsAudioPlayer.swift index f7711c06..781baf2b 100644 --- a/ios/App/App/plugins/AbsAudioPlayer.swift +++ b/ios/App/App/plugins/AbsAudioPlayer.swift @@ -50,6 +50,8 @@ public class AbsAudioPlayer: CAPPlugin { } } @objc func closePlayback(_ call: CAPPluginCall) { + NSLog("Close playback") + PlayerHandler.stopPlayback() call.resolve() } diff --git a/ios/App/Podfile b/ios/App/Podfile index 44119188..584acebb 100644 --- a/ios/App/Podfile +++ b/ios/App/Podfile @@ -9,13 +9,13 @@ install! 'cocoapods', :disable_input_output_paths => true def capacitor_pods pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' - pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app' - pod 'CapacitorDialog', :path => '..\..\node_modules\@capacitor\dialog' - pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics' - pod 'CapacitorNetwork', :path => '..\..\node_modules\@capacitor\network' - pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar' - pod 'CapacitorStorage', :path => '..\..\node_modules\@capacitor\storage' - pod 'RobingenzCapacitorAppUpdate', :path => '..\..\node_modules\@robingenz\capacitor-app-update' + pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' + pod 'CapacitorDialog', :path => '../../node_modules/@capacitor/dialog' + pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' + pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network' + pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' + pod 'CapacitorStorage', :path => '../../node_modules/@capacitor/storage' + pod 'RobingenzCapacitorAppUpdate', :path => '../../node_modules/@robingenz/capacitor-app-update' end target 'App' do diff --git a/ios/App/Shared/player/AudioPlayer.swift b/ios/App/Shared/player/AudioPlayer.swift index 312c94a2..5b87ea61 100644 --- a/ios/App/Shared/player/AudioPlayer.swift +++ b/ios/App/Shared/player/AudioPlayer.swift @@ -74,10 +74,9 @@ class AudioPlayer: NSObject { print(error) } - // DispatchQueue.main.sync { + DispatchQueue.main.sync { UIApplication.shared.endReceivingRemoteControlEvents() - // } - + } NotificationCenter.default.post(name: NSNotification.Name(PlayerEvents.closed.rawValue), object: nil) } @@ -166,7 +165,6 @@ class AudioPlayer: NSObject { "Authorization": "Bearer \(Store.serverConfig!.token)" ] - debugPrint(activeAudioTrack) return AVURLAsset(url: URL(string: "\(Store.serverConfig!.address)\(activeAudioTrack.contentUrl)")!, options: ["AVURLAssetHTTPHeaderFieldsKey": headers]) } private func initAudioSession() { diff --git a/ios/App/Shared/util/NowPlayingInfo.swift b/ios/App/Shared/util/NowPlayingInfo.swift index ec711019..e268ec4c 100644 --- a/ios/App/Shared/util/NowPlayingInfo.swift +++ b/ios/App/Shared/util/NowPlayingInfo.swift @@ -61,6 +61,7 @@ class NowPlayingInfo { MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo } public static func reset() { + nowPlayingInfo = [:] MPNowPlayingInfoCenter.default().nowPlayingInfo = nil }