diff --git a/Example/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj b/Example/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj index 14978c3..694f7fb 100644 --- a/Example/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj +++ b/Example/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 9B8819752BC866A300E20DCE /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B8819702BC866A300E20DCE /* PlayerView.swift */; }; 9B8819782BC866E800E20DCE /* SwiftAudioEx in Frameworks */ = {isa = PBXBuildFile; productRef = 9B8819772BC866E800E20DCE /* SwiftAudioEx */; }; 9B88197A2BC9883200E20DCE /* PlayerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B8819792BC9883200E20DCE /* PlayerViewModel.swift */; }; + 9B88197C2BC98F5000E20DCE /* QueueView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B88197B2BC98F5000E20DCE /* QueueView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -28,6 +29,7 @@ 9B88196F2BC866A300E20DCE /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 9B8819702BC866A300E20DCE /* PlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = ""; }; 9B8819792BC9883200E20DCE /* PlayerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerViewModel.swift; sourceTree = ""; }; + 9B88197B2BC98F5000E20DCE /* QueueView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -68,6 +70,7 @@ 9B8819792BC9883200E20DCE /* PlayerViewModel.swift */, 9B8819702BC866A300E20DCE /* PlayerView.swift */, 9B88195C2BC8657A00E20DCE /* SwiftAudioApp.swift */, + 9B88197B2BC98F5000E20DCE /* QueueView.swift */, 9B8819602BC8657B00E20DCE /* Assets.xcassets */, 9B8819622BC8657B00E20DCE /* SwiftAudio.entitlements */, 9B8819632BC8657B00E20DCE /* Preview Content */, @@ -167,6 +170,7 @@ 9B8819752BC866A300E20DCE /* PlayerView.swift in Sources */, 9B8819712BC866A300E20DCE /* AudioController.swift in Sources */, 9B88197A2BC9883200E20DCE /* PlayerViewModel.swift in Sources */, + 9B88197C2BC98F5000E20DCE /* QueueView.swift in Sources */, 9B88195D2BC8657A00E20DCE /* SwiftAudioApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Example/SwiftAudio/SwiftAudio/PlayerView.swift b/Example/SwiftAudio/SwiftAudio/PlayerView.swift index 8d4c009..6d818d3 100644 --- a/Example/SwiftAudio/SwiftAudio/PlayerView.swift +++ b/Example/SwiftAudio/SwiftAudio/PlayerView.swift @@ -10,6 +10,7 @@ import SwiftAudioEx struct PlayerView: View { @ObservedObject var viewModel: ViewModel + @State private var showingQueue = false let controller = AudioController.shared @@ -21,7 +22,7 @@ struct PlayerView: View { VStack(spacing: 0) { HStack(alignment: .center) { Spacer() - Button(action: {}, label: { + Button(action: { showingQueue.toggle() }, label: { Text("Queue") .fontWeight(.bold) }) @@ -123,6 +124,12 @@ struct PlayerView: View { Spacer() } + .sheet(isPresented: $showingQueue) { + QueueView() +#if os(macOS) + .frame(width: 300, height: 400) +#endif + } .padding(.horizontal, 16) .padding(.top) } diff --git a/Example/SwiftAudio/SwiftAudio/QueueView.swift b/Example/SwiftAudio/SwiftAudio/QueueView.swift new file mode 100644 index 0000000..e7b181c --- /dev/null +++ b/Example/SwiftAudio/SwiftAudio/QueueView.swift @@ -0,0 +1,65 @@ +// +// QueueView.swift +// SwiftAudio +// +// Created by David Chavez on 4/12/24. +// + +import SwiftUI +import SwiftAudioEx + +struct QueueView: View { + let controller = AudioController.shared + @Environment(\.dismiss) var dismiss + + var body: some View { + NavigationStack { + VStack { + List { + if controller.player.currentItem != nil { + Section(header: Text("Playing Now")) { + QueueItemView( + title: controller.player.currentItem?.getTitle() ?? "", + artist: controller.player.currentItem?.getArtist() ?? "" + ) + } + } + Section(header: Text("Up Next")) { + ForEach(controller.player.nextItems as! [DefaultAudioItem]) { item in + QueueItemView( + title: item.getTitle() ?? "", + artist: item.getArtist() ?? "" + ) + } + } + } + } + .navigationTitle("Queue") + .toolbar { + Button("Close") { + dismiss() + } + } + } + } +} + +struct QueueItemView: View { + let title: String + let artist: String + + var body: some View { + VStack(alignment: .leading) { + Text(title) + .fontWeight(.semibold) + Text(artist) + .fontWeight(.light) + } + } +} + + +#Preview { + QueueView() +} + diff --git a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj b/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj deleted file mode 100644 index 0e4642c..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj +++ /dev/null @@ -1,407 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXBuildFile section */ - 070713072067EB4F00F789B3 /* Double + Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 070713062067EB4F00F789B3 /* Double + Extensions.swift */; }; - 070713092067EFFB00F789B3 /* AudioController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 070713082067EFFB00F789B3 /* AudioController.swift */; }; - 0707130B2067F2E000F789B3 /* QueueViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0707130A2067F2E000F789B3 /* QueueViewController.swift */; }; - 0707130F2067F40A00F789B3 /* QueueTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0707130D2067F40A00F789B3 /* QueueTableViewCell.swift */; }; - 070713102067F40A00F789B3 /* QueueTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0707130E2067F40A00F789B3 /* QueueTableViewCell.xib */; }; - 461B275E2BB89747004E6744 /* SwiftAudioEx in Frameworks */ = {isa = PBXBuildFile; productRef = 461B275D2BB89747004E6744 /* SwiftAudioEx */; }; - 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; - 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; - 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; - 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; - 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 070713062067EB4F00F789B3 /* Double + Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Double + Extensions.swift"; sourceTree = ""; }; - 070713082067EFFB00F789B3 /* AudioController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioController.swift; sourceTree = ""; }; - 0707130A2067F2E000F789B3 /* QueueViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueViewController.swift; sourceTree = ""; }; - 0707130D2067F40A00F789B3 /* QueueTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueueTableViewCell.swift; sourceTree = ""; }; - 0707130E2067F40A00F789B3 /* QueueTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QueueTableViewCell.xib; sourceTree = ""; }; - 461B27592BB89735004E6744 /* SwiftAudioEx */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftAudioEx; path = ../../..; sourceTree = ""; }; - 607FACD01AFB9204008FA782 /* SwiftAudio_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftAudio_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 607FACCD1AFB9204008FA782 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 461B275E2BB89747004E6744 /* SwiftAudioEx in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 461B275C2BB89747004E6744 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; - 607FACC71AFB9204008FA782 = { - isa = PBXGroup; - children = ( - 461B27592BB89735004E6744 /* SwiftAudioEx */, - 607FACD21AFB9204008FA782 /* Example for SwiftAudio */, - 607FACD11AFB9204008FA782 /* Products */, - 461B275C2BB89747004E6744 /* Frameworks */, - ); - sourceTree = ""; - }; - 607FACD11AFB9204008FA782 /* Products */ = { - isa = PBXGroup; - children = ( - 607FACD01AFB9204008FA782 /* SwiftAudio_Example.app */, - ); - name = Products; - sourceTree = ""; - }; - 607FACD21AFB9204008FA782 /* Example for SwiftAudio */ = { - isa = PBXGroup; - children = ( - 607FACD51AFB9204008FA782 /* AppDelegate.swift */, - 070713082067EFFB00F789B3 /* AudioController.swift */, - 607FACD71AFB9204008FA782 /* ViewController.swift */, - 0707130A2067F2E000F789B3 /* QueueViewController.swift */, - 070713062067EB4F00F789B3 /* Double + Extensions.swift */, - 0707130D2067F40A00F789B3 /* QueueTableViewCell.swift */, - 0707130E2067F40A00F789B3 /* QueueTableViewCell.xib */, - 607FACD91AFB9204008FA782 /* Main.storyboard */, - 607FACDC1AFB9204008FA782 /* Images.xcassets */, - 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, - 607FACD31AFB9204008FA782 /* Supporting Files */, - ); - name = "Example for SwiftAudio"; - path = SwiftAudio; - sourceTree = ""; - }; - 607FACD31AFB9204008FA782 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 607FACD41AFB9204008FA782 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 607FACCF1AFB9204008FA782 /* SwiftAudio_Example */ = { - isa = PBXNativeTarget; - buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftAudio_Example" */; - buildPhases = ( - 607FACCC1AFB9204008FA782 /* Sources */, - 607FACCD1AFB9204008FA782 /* Frameworks */, - 607FACCE1AFB9204008FA782 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 461B275B2BB89740004E6744 /* PBXTargetDependency */, - ); - name = SwiftAudio_Example; - packageProductDependencies = ( - 461B275D2BB89747004E6744 /* SwiftAudioEx */, - ); - productName = SwiftAudio; - productReference = 607FACD01AFB9204008FA782 /* SwiftAudio_Example.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 607FACC81AFB9204008FA782 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 1530; - ORGANIZATIONNAME = CocoaPods; - TargetAttributes = { - 607FACCF1AFB9204008FA782 = { - CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 1020; - SystemCapabilities = { - com.apple.BackgroundModes = { - enabled = 1; - }; - }; - }; - }; - }; - buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftAudio" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 607FACC71AFB9204008FA782; - packageReferences = ( - ); - productRefGroup = 607FACD11AFB9204008FA782 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 607FACCF1AFB9204008FA782 /* SwiftAudio_Example */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 607FACCE1AFB9204008FA782 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, - 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, - 070713102067F40A00F789B3 /* QueueTableViewCell.xib in Resources */, - 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 607FACCC1AFB9204008FA782 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0707130B2067F2E000F789B3 /* QueueViewController.swift in Sources */, - 070713072067EB4F00F789B3 /* Double + Extensions.swift in Sources */, - 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, - 0707130F2067F40A00F789B3 /* QueueTableViewCell.swift in Sources */, - 070713092067EFFB00F789B3 /* AudioController.swift in Sources */, - 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 461B275B2BB89740004E6744 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - productRef = 461B275A2BB89740004E6744 /* SwiftAudioEx */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 607FACD91AFB9204008FA782 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 607FACDA1AFB9204008FA782 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 607FACDF1AFB9204008FA782 /* Base */, - ); - name = LaunchScreen.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 607FACED1AFB9204008FA782 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 607FACEE1AFB9204008FA782 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 607FACF01AFB9204008FA782 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7U2TUNKNQX; - INFOPLIST_FILE = SwiftAudio/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MODULE_NAME = ExampleApp; - PRODUCT_BUNDLE_IDENTIFIER = "com.doublesymmetry.demo.--PRODUCT-NAME-rfc1034identifier-"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; - }; - name = Debug; - }; - 607FACF11AFB9204008FA782 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 7U2TUNKNQX; - INFOPLIST_FILE = SwiftAudio/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MODULE_NAME = ExampleApp; - PRODUCT_BUNDLE_IDENTIFIER = "com.doublesymmetry.demo.--PRODUCT-NAME-rfc1034identifier-"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = 1; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftAudio" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 607FACED1AFB9204008FA782 /* Debug */, - 607FACEE1AFB9204008FA782 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftAudio_Example" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 607FACF01AFB9204008FA782 /* Debug */, - 607FACF11AFB9204008FA782 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCSwiftPackageProductDependency section */ - 461B275A2BB89740004E6744 /* SwiftAudioEx */ = { - isa = XCSwiftPackageProductDependency; - productName = SwiftAudioEx; - }; - 461B275D2BB89747004E6744 /* SwiftAudioEx */ = { - isa = XCSwiftPackageProductDependency; - productName = SwiftAudioEx; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = 607FACC81AFB9204008FA782 /* Project object */; -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/xcshareddata/xcschemes/SwiftAudio-Example.xcscheme b/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/xcshareddata/xcschemes/SwiftAudio-Example.xcscheme deleted file mode 100644 index 74884e0..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio.xcodeproj/xcshareddata/xcschemes/SwiftAudio-Example.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/AppDelegate.swift b/Example/iOS/SwiftAudio/SwiftAudio/AppDelegate.swift deleted file mode 100644 index f09f61f..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/AppDelegate.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// AppDelegate.swift -// SwiftAudio -// -// Created by Jørgen Henrichsen on 03/11/2018. -// Copyright (c) 2018 Jørgen Henrichsen. All rights reserved. -// - -import UIKit - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - - var window: UIWindow? - - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - - application.beginReceivingRemoteControlEvents() - return true - } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - -} - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/AudioController.swift b/Example/iOS/SwiftAudio/SwiftAudio/AudioController.swift deleted file mode 100644 index b011b57..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/AudioController.swift +++ /dev/null @@ -1,48 +0,0 @@ -// -// AudioController.swift -// SwiftAudio_Example -// -// Created by Jørgen Henrichsen on 25/03/2018. -// Copyright © 2018 CocoaPods. All rights reserved. -// - -import Foundation -import SwiftAudioEx - - -class AudioController { - - static let shared = AudioController() - let player: QueuedAudioPlayer - let audioSessionController = AudioSessionController.shared - - let sources: [AudioItem] = [ - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Longing.mp3", artist: "David Chavez", title: "Longing", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Soul%20Searching.mp3", artist: "David Chavez", title: "Soul Searching (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Lullaby%20(Demo).mp3", artist: "David Chavez", title: "Lullaby (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Rhythm%20City%20(Demo).mp3", artist: "David Chavez", title: "Rhythm City (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/hls/whip/playlist.m3u8", title: "Whip", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://ais-sa5.cdnstream1.com/b75154_128mp3", artist: "New York, NY", title: "Smooth Jazz 24/7", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://traffic.libsyn.com/atpfm/atp545.mp3", title: "Chapters", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - ] - - init() { - let controller = RemoteCommandController() - player = QueuedAudioPlayer(remoteCommandController: controller) - player.remoteCommands = [ - .stop, - .play, - .pause, - .togglePlayPause, - .next, - .previous, - .changePlaybackPosition - ] - try? audioSessionController.set(category: .playback) - player.repeatMode = .queue - DispatchQueue.main.async { - self.player.add(items: self.sources) - } - } - -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/LaunchScreen.xib b/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/LaunchScreen.xib deleted file mode 100644 index ae9e866..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/Main.storyboard b/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/Main.storyboard deleted file mode 100644 index 6defe98..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Base.lproj/Main.storyboard +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Double + Extensions.swift b/Example/iOS/SwiftAudio/SwiftAudio/Double + Extensions.swift deleted file mode 100644 index 9dfa4ba..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Double + Extensions.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Double + Extensions.swift -// SwiftAudio_Example -// -// Created by Jørgen Henrichsen on 25/03/2018. -// Copyright © 2018 CocoaPods. All rights reserved. -// - -import Foundation - -extension Double { - - private var formatter: DateComponentsFormatter { - let formatter = DateComponentsFormatter() - formatter.allowedUnits = [.minute, .second] - formatter.unitsStyle = .positional - formatter.zeroFormattingBehavior = .pad - return formatter - } - - func secondsToString() -> String { - return formatter.string(from: self) ?? "" - } - -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/22AMillion.jpg b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/22AMillion.jpg deleted file mode 100644 index 4f5c56f..0000000 Binary files a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/22AMillion.jpg and /dev/null differ diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/Contents.json b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/Contents.json deleted file mode 100644 index 4ef2565..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/22AMI.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "22AMillion.jpg", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 7006c9e..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/Contents.json b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/Contents.json deleted file mode 100644 index da4a164..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/Contents.json b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/Contents.json deleted file mode 100644 index 3ab2f00..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "cover.jpg", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/cover.jpg b/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/cover.jpg deleted file mode 100644 index 5309f2a..0000000 Binary files a/Example/iOS/SwiftAudio/SwiftAudio/Images.xcassets/cover.imageset/cover.jpg and /dev/null differ diff --git a/Example/iOS/SwiftAudio/SwiftAudio/Info.plist b/Example/iOS/SwiftAudio/SwiftAudio/Info.plist deleted file mode 100644 index 344f68b..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/Info.plist +++ /dev/null @@ -1,48 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UIBackgroundModes - - audio - remote-notification - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UIStatusBarStyle - UIStatusBarStyleLightContent - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - - UIViewControllerBasedStatusBarAppearance - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.swift b/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.swift deleted file mode 100644 index b53a628..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// QueueTableViewCell.swift -// SwiftAudio_Example -// -// Created by Jørgen Henrichsen on 25/03/2018. -// Copyright © 2018 CocoaPods. All rights reserved. -// - -import UIKit - -class QueueTableViewCell: UITableViewCell { - - @IBOutlet weak var titleLabel: UILabel! - @IBOutlet weak var artistLabel: UILabel! - - override func awakeFromNib() { - super.awakeFromNib() - } - - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - } - -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.xib b/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.xib deleted file mode 100644 index 245b7b1..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/QueueTableViewCell.xib +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Example/iOS/SwiftAudio/SwiftAudio/QueueViewController.swift b/Example/iOS/SwiftAudio/SwiftAudio/QueueViewController.swift deleted file mode 100644 index 715fc76..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/QueueViewController.swift +++ /dev/null @@ -1,84 +0,0 @@ -// -// QueueViewController.swift -// SwiftAudio_Example -// -// Created by Jørgen Henrichsen on 25/03/2018. -// Copyright © 2018 CocoaPods. All rights reserved. -// - -import UIKit -import SwiftAudioEx - - -class QueueViewController: UIViewController { - - let controller = AudioController.shared - @IBOutlet weak var tableView: UITableView! - - let cellReuseId: String = "QueueCell" - - override func viewDidLoad() { - super.viewDidLoad() - - tableView.register(UINib.init(nibName: "QueueTableViewCell", bundle: Bundle.main), forCellReuseIdentifier: cellReuseId) - tableView.delegate = self - tableView.dataSource = self - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - } - - @IBAction func closeButton(_ sender: UIButton) { - self.dismiss(animated: true, completion: nil) - } - -} - -extension QueueViewController: UITableViewDataSource, UITableViewDelegate { - - func numberOfSections(in tableView: UITableView) -> Int { - return 2 - } - - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - switch section { - case 0: - return 1 - case 1: - return controller.player.nextItems.count - default: - return 0 - } - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseId, for: indexPath) as! QueueTableViewCell - - let item: AudioItem? - switch indexPath.section { - case 0: - item = controller.player.currentItem - case 1: - item = controller.player.nextItems[indexPath.row] - default: - item = nil - } - - if let item = item { - cell.titleLabel.text = item.getTitle() - cell.artistLabel.text = item.getArtist() - } - - return cell - } - - func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { - switch section { - case 0: return "Playing Now" - case 1: return "Up Next" - default: return nil - } - } - -} diff --git a/Example/iOS/SwiftAudio/SwiftAudio/ViewController.swift b/Example/iOS/SwiftAudio/SwiftAudio/ViewController.swift deleted file mode 100644 index eba4f89..0000000 --- a/Example/iOS/SwiftAudio/SwiftAudio/ViewController.swift +++ /dev/null @@ -1,169 +0,0 @@ -// -// ViewController.swift -// SwiftAudio -// -// Created by Jørgen Henrichsen on 03/11/2018. -// Copyright (c) 2018 Jørgen Henrichsen. All rights reserved. -// - -import UIKit -import SwiftAudioEx -import AVFoundation -import MediaPlayer - - -class ViewController: UIViewController { - - @IBOutlet weak var playButton: UIButton! - @IBOutlet weak var slider: UISlider! - @IBOutlet weak var imageView: UIImageView! - @IBOutlet weak var remainingTimeLabel: UILabel! - @IBOutlet weak var elapsedTimeLabel: UILabel! - @IBOutlet weak var titleLabel: UILabel! - @IBOutlet weak var artistLabel: UILabel! - @IBOutlet weak var loadIndicator: UIActivityIndicatorView! - @IBOutlet weak var errorLabel: UILabel! - - private var isScrubbing: Bool = false - private let controller = AudioController.shared - - override func viewDidLoad() { - super.viewDidLoad() - controller.player.event.playWhenReadyChange.addListener(self, handlePlayWhenReadyChange) - controller.player.event.stateChange.addListener(self, handleAudioPlayerStateChange) - controller.player.event.playbackEnd.addListener(self, handleAudioPlayerPlaybackEnd(data:)) - controller.player.event.secondElapse.addListener(self, handleAudioPlayerSecondElapsed) - controller.player.event.seek.addListener(self, handleAudioPlayerDidSeek) - controller.player.event.updateDuration.addListener(self, handleAudioPlayerUpdateDuration) - controller.player.event.didRecreateAVPlayer.addListener(self, handleAVPlayerRecreated) - handleAudioPlayerStateChange(data: controller.player.playerState) - DispatchQueue.main.async { - self.render() - } - } - - // MARK: - Actions - - @IBAction func togglePlay(_ sender: Any) { - if !controller.audioSessionController.audioSessionIsActive { - try? controller.audioSessionController.activateSession() - } - controller.player.playWhenReady = playButton.currentTitle == "Play" - } - - @IBAction func previous(_ sender: Any) { - controller.player.previous() - } - - @IBAction func next(_ sender: Any) { - controller.player.next() - } - - @IBAction func startScrubbing(_ sender: UISlider) { - isScrubbing = true - } - - @IBAction func scrubbing(_ sender: UISlider) { - controller.player.seek(to: Double(slider.value)) - } - - @IBAction func scrubbingValueChanged(_ sender: UISlider) { - let value = Double(slider.value) - elapsedTimeLabel.text = value.secondsToString() - remainingTimeLabel.text = (controller.player.duration - value).secondsToString() - } - - // MARK: - Render - - func renderTimeValues() { - self.slider.maximumValue = Float(self.controller.player.duration) - self.slider.setValue(Float(self.controller.player.currentTime), animated: true) - self.elapsedTimeLabel.text = self.controller.player.currentTime.secondsToString() - self.remainingTimeLabel.text = (self.controller.player.duration - self.controller.player.currentTime).secondsToString() - } - - func render() { - let player = self.controller.player - - // Render play button - self.playButton.setTitle( - !player.playWhenReady || player.playerState == .failed - ? "Play" - : "Pause", - for: .normal - ) - - // Render metadata - if let item = player.currentItem { - self.titleLabel.text = item.getTitle() - self.artistLabel.text = item.getArtist() - item.getArtwork({ (image) in - self.imageView.image = image - }) - } - - // Render time values - self.renderTimeValues() - - // Render error label - if (player.playerState == .failed) { - self.errorLabel.isHidden = false - self.errorLabel.text = "Playback failed." - } else { - self.errorLabel.text = "" - self.errorLabel.isHidden = true - } - - // Render load indicator: - if ( - (player.playerState == .loading || player.playerState == .buffering) - && self.controller.player.playWhenReady // Avoid showing indicator before user has pressed play - ) { - self.loadIndicator.startAnimating() - } else { - self.loadIndicator.stopAnimating() - } - } - - // MARK: - AudioPlayer Event Handlers - - func handleAudioPlayerStateChange(data: AudioPlayer.StateChangeEventData) { - print("state=\(data)") - DispatchQueue.main.async { - self.render() - } - } - - func handlePlayWhenReadyChange(data: AudioPlayer.PlayWhenReadyChangeData) { - print("playWhenReady=\(data)") - DispatchQueue.main.async { - self.render() - } - } - - func handleAudioPlayerPlaybackEnd(data: AudioPlayer.PlaybackEndEventData) { - print("playEndReason=\(data)") - } - - func handleAudioPlayerSecondElapsed(data: AudioPlayer.SecondElapseEventData) { - if !isScrubbing { - DispatchQueue.main.async { - self.renderTimeValues() - } - } - } - - func handleAudioPlayerDidSeek(data: AudioPlayer.SeekEventData) { - isScrubbing = false - } - - func handleAudioPlayerUpdateDuration(data: AudioPlayer.UpdateDurationEventData) { - DispatchQueue.main.async { - self.renderTimeValues() - } - } - - func handleAVPlayerRecreated() { - try? controller.audioSessionController.set(category: .playback) - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj b/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj deleted file mode 100644 index 4d7993a..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj +++ /dev/null @@ -1,396 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 56; - objects = { - -/* Begin PBXBuildFile section */ - 461B27412BB89512004E6744 /* SwiftAudioApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B27402BB89512004E6744 /* SwiftAudioApp.swift */; }; - 461B27432BB89512004E6744 /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B27422BB89512004E6744 /* PlayerView.swift */; }; - 461B27452BB89512004E6744 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 461B27442BB89512004E6744 /* Assets.xcassets */; }; - 461B27482BB89512004E6744 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 461B27472BB89512004E6744 /* Preview Assets.xcassets */; }; - 461B27542BB89606004E6744 /* SwiftAudioEx in Frameworks */ = {isa = PBXBuildFile; productRef = 461B27532BB89606004E6744 /* SwiftAudioEx */; }; - 461B27582BB8968A004E6744 /* AudioController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B27572BB8968A004E6744 /* AudioController.swift */; }; - 461B27602BB89846004E6744 /* PlayerState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B275F2BB89846004E6744 /* PlayerState.swift */; }; - 461B27642BB89CA7004E6744 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B27632BB89CA7004E6744 /* Extensions.swift */; }; - 461B27662BB9FFBC004E6744 /* PlayerListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 461B27652BB9FFBC004E6744 /* PlayerListener.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 461B273D2BB89512004E6744 /* SwiftAudio.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftAudio.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 461B27402BB89512004E6744 /* SwiftAudioApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftAudioApp.swift; sourceTree = ""; }; - 461B27422BB89512004E6744 /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = ""; }; - 461B27442BB89512004E6744 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 461B27472BB89512004E6744 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 461B27492BB89512004E6744 /* SwiftAudio.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftAudio.entitlements; sourceTree = ""; }; - 461B274F2BB895E2004E6744 /* SwiftAudioEx */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftAudioEx; path = ../../..; sourceTree = ""; }; - 461B27572BB8968A004E6744 /* AudioController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioController.swift; sourceTree = ""; }; - 461B275F2BB89846004E6744 /* PlayerState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerState.swift; sourceTree = ""; }; - 461B27632BB89CA7004E6744 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; - 461B27652BB9FFBC004E6744 /* PlayerListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerListener.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 461B273A2BB89512004E6744 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 461B27542BB89606004E6744 /* SwiftAudioEx in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 461B27342BB89512004E6744 = { - isa = PBXGroup; - children = ( - 461B274F2BB895E2004E6744 /* SwiftAudioEx */, - 461B273F2BB89512004E6744 /* SwiftAudio */, - 461B273E2BB89512004E6744 /* Products */, - 461B27522BB89606004E6744 /* Frameworks */, - ); - sourceTree = ""; - }; - 461B273E2BB89512004E6744 /* Products */ = { - isa = PBXGroup; - children = ( - 461B273D2BB89512004E6744 /* SwiftAudio.app */, - ); - name = Products; - sourceTree = ""; - }; - 461B273F2BB89512004E6744 /* SwiftAudio */ = { - isa = PBXGroup; - children = ( - 461B27402BB89512004E6744 /* SwiftAudioApp.swift */, - 461B27632BB89CA7004E6744 /* Extensions.swift */, - 461B275F2BB89846004E6744 /* PlayerState.swift */, - 461B27572BB8968A004E6744 /* AudioController.swift */, - 461B27422BB89512004E6744 /* PlayerView.swift */, - 461B27652BB9FFBC004E6744 /* PlayerListener.swift */, - 461B27442BB89512004E6744 /* Assets.xcassets */, - 461B27492BB89512004E6744 /* SwiftAudio.entitlements */, - 461B27462BB89512004E6744 /* Preview Content */, - ); - path = SwiftAudio; - sourceTree = ""; - }; - 461B27462BB89512004E6744 /* Preview Content */ = { - isa = PBXGroup; - children = ( - 461B27472BB89512004E6744 /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; - 461B27522BB89606004E6744 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 461B273C2BB89512004E6744 /* SwiftAudio */ = { - isa = PBXNativeTarget; - buildConfigurationList = 461B274C2BB89512004E6744 /* Build configuration list for PBXNativeTarget "SwiftAudio" */; - buildPhases = ( - 461B27392BB89512004E6744 /* Sources */, - 461B273A2BB89512004E6744 /* Frameworks */, - 461B273B2BB89512004E6744 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 461B27512BB895FE004E6744 /* PBXTargetDependency */, - ); - name = SwiftAudio; - packageProductDependencies = ( - 461B27532BB89606004E6744 /* SwiftAudioEx */, - ); - productName = SwiftAudio; - productReference = 461B273D2BB89512004E6744 /* SwiftAudio.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 461B27352BB89512004E6744 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1530; - LastUpgradeCheck = 1530; - TargetAttributes = { - 461B273C2BB89512004E6744 = { - CreatedOnToolsVersion = 15.3; - }; - }; - }; - buildConfigurationList = 461B27382BB89512004E6744 /* Build configuration list for PBXProject "SwiftAudio" */; - compatibilityVersion = "Xcode 14.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 461B27342BB89512004E6744; - productRefGroup = 461B273E2BB89512004E6744 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 461B273C2BB89512004E6744 /* SwiftAudio */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 461B273B2BB89512004E6744 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 461B27482BB89512004E6744 /* Preview Assets.xcassets in Resources */, - 461B27452BB89512004E6744 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 461B27392BB89512004E6744 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 461B27642BB89CA7004E6744 /* Extensions.swift in Sources */, - 461B27432BB89512004E6744 /* PlayerView.swift in Sources */, - 461B27582BB8968A004E6744 /* AudioController.swift in Sources */, - 461B27602BB89846004E6744 /* PlayerState.swift in Sources */, - 461B27662BB9FFBC004E6744 /* PlayerListener.swift in Sources */, - 461B27412BB89512004E6744 /* SwiftAudioApp.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 461B27512BB895FE004E6744 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - productRef = 461B27502BB895FE004E6744 /* SwiftAudioEx */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 461B274A2BB89512004E6744 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 14.3; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 461B274B2BB89512004E6744 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; - GCC_C_LANGUAGE_STANDARD = gnu17; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 14.3; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - }; - name = Release; - }; - 461B274D2BB89512004E6744 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = SwiftAudio/SwiftAudio.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"SwiftAudio/Preview Content\""; - DEVELOPMENT_TEAM = 7U2TUNKNQX; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 14.2; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.doublesymmetry.SwiftAudio; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 461B274E2BB89512004E6744 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = SwiftAudio/SwiftAudio.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"SwiftAudio/Preview Content\""; - DEVELOPMENT_TEAM = 7U2TUNKNQX; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - MACOSX_DEPLOYMENT_TARGET = 14.2; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.doublesymmetry.SwiftAudio; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 461B27382BB89512004E6744 /* Build configuration list for PBXProject "SwiftAudio" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 461B274A2BB89512004E6744 /* Debug */, - 461B274B2BB89512004E6744 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 461B274C2BB89512004E6744 /* Build configuration list for PBXNativeTarget "SwiftAudio" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 461B274D2BB89512004E6744 /* Debug */, - 461B274E2BB89512004E6744 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCSwiftPackageProductDependency section */ - 461B27502BB895FE004E6744 /* SwiftAudioEx */ = { - isa = XCSwiftPackageProductDependency; - productName = SwiftAudioEx; - }; - 461B27532BB89606004E6744 /* SwiftAudioEx */ = { - isa = XCSwiftPackageProductDependency; - productName = SwiftAudioEx; - }; -/* End XCSwiftPackageProductDependency section */ - }; - rootObject = 461B27352BB89512004E6744 /* Project object */; -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/22AMillion.jpg b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/22AMillion.jpg deleted file mode 100644 index 4f5c56f..0000000 Binary files a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/22AMillion.jpg and /dev/null differ diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/Contents.json deleted file mode 100644 index ba6137a..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/22AMI.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "filename" : "22AMillion.jpg", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb87897..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 3f00db4..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "scale" : "1x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "512x512" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "512x512" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/Contents.json deleted file mode 100644 index c1fd1c5..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "filename" : "cover.jpg", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/cover.jpg b/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/cover.jpg deleted file mode 100644 index 5309f2a..0000000 Binary files a/Example/macOS/SwiftAudio/SwiftAudio/Assets.xcassets/cover.imageset/cover.jpg and /dev/null differ diff --git a/Example/macOS/SwiftAudio/SwiftAudio/AudioController.swift b/Example/macOS/SwiftAudio/SwiftAudio/AudioController.swift deleted file mode 100644 index ff75fd2..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/AudioController.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// AudioController.swift -// SwiftAudio_Example -// -// Created by Jørgen Henrichsen on 25/03/2018. -// Copyright © 2018 CocoaPods. All rights reserved. -// - -import Foundation -import SwiftAudioEx - -class AudioController { - - static let shared = AudioController() - let player: QueuedAudioPlayer - - let sources: [AudioItem] = [ - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Longing.mp3", artist: "David Chavez", title: "Longing", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Soul%20Searching.mp3", artist: "David Chavez", title: "Soul Searching (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Lullaby%20(Demo).mp3", artist: "David Chavez", title: "Lullaby (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "cover")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/Rhythm%20City%20(Demo).mp3", artist: "David Chavez", title: "Rhythm City (Demo)", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://rntp.dev/example/hls/whip/playlist.m3u8", title: "Whip", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - DefaultAudioItem(audioUrl: "https://ais-sa5.cdnstream1.com/b75154_128mp3", artist: "New York, NY", title: "Smooth Jazz 24/7", sourceType: .stream, artwork: #imageLiteral(resourceName: "cover")), - DefaultAudioItem(audioUrl: "https://traffic.libsyn.com/atpfm/atp545.mp3", title: "Chapters", sourceType: .stream, artwork: #imageLiteral(resourceName: "22AMI")), - ] - - init() { - let controller = RemoteCommandController() - player = QueuedAudioPlayer(remoteCommandController: controller) - player.remoteCommands = [ - .stop, - .play, - .pause, - .togglePlayPause, - .next, - .previous, - .changePlaybackPosition - ] - - player.repeatMode = .queue - DispatchQueue.main.async { - self.player.add(items: self.sources) - } - } - -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Extensions.swift b/Example/macOS/SwiftAudio/SwiftAudio/Extensions.swift deleted file mode 100644 index 53b0295..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Extensions.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// Extensions.swift -// SwiftAudio -// -// Created by Brandon Sneed on 3/30/24. -// - -import Foundation - -extension Double { - private var formatter: DateComponentsFormatter { - let formatter = DateComponentsFormatter() - formatter.allowedUnits = [.minute, .second] - formatter.unitsStyle = .positional - formatter.zeroFormattingBehavior = .pad - return formatter - } - - func secondsToString() -> String { - return formatter.string(from: self) ?? "" - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/PlayerListener.swift b/Example/macOS/SwiftAudio/SwiftAudio/PlayerListener.swift deleted file mode 100644 index 6605b13..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/PlayerListener.swift +++ /dev/null @@ -1,92 +0,0 @@ -// -// PlayerListener.swift -// SwiftAudio -// -// Created by Brandon Sneed on 3/31/24. -// - -import Foundation -import SwiftAudioEx - -class PlayerListener { - var state: PlayerState - let controller = AudioController.shared - - init(state: PlayerState) { - self.state = state - - controller.player.event.playWhenReadyChange.addListener(self, handlePlayWhenReadyChange) - controller.player.event.stateChange.addListener(self, handleAudioPlayerStateChange) - controller.player.event.playbackEnd.addListener(self, handleAudioPlayerPlaybackEnd(data:)) - controller.player.event.secondElapse.addListener(self, handleAudioPlayerSecondElapsed) - controller.player.event.seek.addListener(self, handleAudioPlayerDidSeek) - controller.player.event.updateDuration.addListener(self, handleAudioPlayerUpdateDuration) - controller.player.event.didRecreateAVPlayer.addListener(self, handleAVPlayerRecreated) - render() - } - - func render() { - DispatchQueue.main.async { [weak self] in - guard let self else { return } - state.playing = (controller.player.playerState == .playing) - state.position = controller.player.currentTime - state.maxTime = controller.player.duration - state.artist = controller.player.currentItem?.getArtist() ?? "" - state.title = controller.player.currentItem?.getTitle() ?? "" - state.elapsedTime = controller.player.currentTime.secondsToString() - state.remainingTime = (controller.player.duration - controller.player.currentTime).secondsToString() - if let item = controller.player.currentItem as? DefaultAudioItem { - state.artwork = item.artwork - } else { - state.artwork = nil - } - } - } - - func renderTimes() { - DispatchQueue.main.async { [weak self] in - guard let self else { return } - state.position = controller.player.currentTime - state.maxTime = controller.player.duration - state.elapsedTime = controller.player.currentTime.secondsToString() - state.remainingTime = (controller.player.duration - controller.player.currentTime).secondsToString() - print(state.elapsedTime) - } - } - - // MARK: - AudioPlayer Event Handlers - - func handleAudioPlayerStateChange(data: AudioPlayer.StateChangeEventData) { - print("state=\(data)") - self.render() - } - - func handlePlayWhenReadyChange(data: AudioPlayer.PlayWhenReadyChangeData) { - print("playWhenReady=\(data)") - self.render() - } - - func handleAudioPlayerPlaybackEnd(data: AudioPlayer.PlaybackEndEventData) { - print("playEndReason=\(data)") - } - - func handleAudioPlayerSecondElapsed(data: AudioPlayer.SecondElapseEventData) { - if !state.isScrubbing { - self.renderTimes() - } - } - - func handleAudioPlayerDidSeek(data: AudioPlayer.SeekEventData) { - // .. don't need this - } - - func handleAudioPlayerUpdateDuration(data: AudioPlayer.UpdateDurationEventData) { - if !state.isScrubbing { - self.renderTimes() - } - } - - func handleAVPlayerRecreated() { - // .. don't need this - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/PlayerState.swift b/Example/macOS/SwiftAudio/SwiftAudio/PlayerState.swift deleted file mode 100644 index 891d6ce..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/PlayerState.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// PlayerState.swift -// SwiftAudio -// -// Created by Brandon Sneed on 3/30/24. -// - -import Foundation -import SwiftAudioEx -import AppKit -import SwiftUI - -class PlayerState: ObservableObject { - @Published var playing: Bool = false - @Published var position: Double = 0 - @Published var artwork: NSImage? = nil - @Published var title: String = "" - @Published var artist: String = "" - @Published var maxTime: TimeInterval = 100 - @Published var isScrubbing: Bool = false - @Published var elapsedTime: String = "00:00" - @Published var remainingTime: String = "00:00" -} - - diff --git a/Example/macOS/SwiftAudio/SwiftAudio/PlayerView.swift b/Example/macOS/SwiftAudio/SwiftAudio/PlayerView.swift deleted file mode 100644 index fd714dc..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/PlayerView.swift +++ /dev/null @@ -1,88 +0,0 @@ -// -// PlayerView.swift -// SwiftAudio -// -// Created by Brandon Sneed on 3/30/24. -// - -import SwiftUI -import SwiftAudioEx - -struct PlayerView: View { - @ObservedObject var state: PlayerState - - let controller = AudioController.shared - let listener: PlayerListener - - var body: some View { - VStack { - Spacer() - HStack(alignment: .center) { - Spacer() - Button("Queue") { - // open the queue - } - } - - if let image = state.artwork { - Image(nsImage: image) - .resizable() - .scaledToFit() - .frame(width: 500, height: 500) - } else { - AsyncImage(url: nil) - .frame(width: 500, height: 500) - } - - Text(state.title) - .bold() - Text(state.artist) - if state.maxTime > 0 { - Slider(value: $state.position, in: 0...state.maxTime) { editing in - state.isScrubbing = editing - print("scrubbing = \(state.isScrubbing)") - if state.isScrubbing == false { - controller.player.seek(to: state.position) - } - } - HStack { - Text(state.elapsedTime) - Spacer() - Text(state.remainingTime) - } - } else { - Text("Live Streaming") - Spacer() - } - - HStack { - Button("Prev") { - controller.player.next() - } - - Button(state.playing ? "Pause" : "Play") { - if state.playing { - controller.player.pause() - } else { - controller.player.play() - } - }.bold() - - Button("Next") { - controller.player.next() - } - } - - Spacer() - Spacer() - Spacer() - } - .padding() - } - - init(state: PlayerState, listener: PlayerListener) { - self.state = state - self.listener = listener - } -} - diff --git a/Example/macOS/SwiftAudio/SwiftAudio/Preview Content/Preview Assets.xcassets/Contents.json b/Example/macOS/SwiftAudio/SwiftAudio/Preview Content/Preview Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudio.entitlements b/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudio.entitlements deleted file mode 100644 index 625af03..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudio.entitlements +++ /dev/null @@ -1,12 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - - com.apple.security.network.client - - - diff --git a/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudioApp.swift b/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudioApp.swift deleted file mode 100644 index 6916f56..0000000 --- a/Example/macOS/SwiftAudio/SwiftAudio/SwiftAudioApp.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// SwiftAudioApp.swift -// SwiftAudio -// -// Created by Brandon Sneed on 3/30/24. -// - -import SwiftUI - -@main -struct SwiftAudioApp: App { - let state: PlayerState - let listener: PlayerListener - - var body: some Scene { - WindowGroup { - PlayerView(state: state, listener: listener) - } - } - - init() { - let state = PlayerState() - self.state = state - self.listener = PlayerListener(state: state) - } -} diff --git a/Sources/SwiftAudioEx/AudioItem.swift b/Sources/SwiftAudioEx/AudioItem.swift index 833afe3..0544750 100755 --- a/Sources/SwiftAudioEx/AudioItem.swift +++ b/Sources/SwiftAudioEx/AudioItem.swift @@ -22,7 +22,6 @@ public enum SourceType { } public protocol AudioItem { - func getSourceUrl() -> String func getArtist() -> String? func getTitle() -> String? @@ -34,7 +33,6 @@ public protocol AudioItem { /// Make your `AudioItem`-subclass conform to this protocol to control which AVAudioTimePitchAlgorithm is used for each item. public protocol TimePitching { - func getPitchAlgorithmType() -> AVAudioTimePitchAlgorithm } @@ -49,8 +47,8 @@ public protocol AssetOptionsProviding { func getAssetOptions() -> [String: Any] } -public class DefaultAudioItem: AudioItem { - +public class DefaultAudioItem: AudioItem, Identifiable { + public var audioUrl: String public var artist: String?