diff --git a/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/Contents.json b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/Contents.json new file mode 100644 index 00000000..1ecf6fb1 --- /dev/null +++ b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "ic_cast_connected_white_24dp-2.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ic_cast_connected_white_24dp-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ic_cast_connected_white_24dp.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-1.png b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-1.png new file mode 100644 index 00000000..dcba78d8 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-1.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-2.png b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-2.png new file mode 100644 index 00000000..dcba78d8 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp-2.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp.png b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp.png new file mode 100644 index 00000000..caffc5ba Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnected.imageset/ic_cast_connected_white_24dp.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/Contents.json b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/Contents.json new file mode 100644 index 00000000..1bd4c545 --- /dev/null +++ b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "ic_cast0_white_24dp.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ic_cast0_white_24dp-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ic_cast0_white_24dp-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-1.png b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-1.png new file mode 100644 index 00000000..a0670a4f Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-1.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-2.png b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-2.png new file mode 100644 index 00000000..cab042ba Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp-2.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp.png b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp.png new file mode 100644 index 00000000..a0670a4f Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting0.imageset/ic_cast0_white_24dp.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/Contents.json b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/Contents.json new file mode 100644 index 00000000..9f65b6bb --- /dev/null +++ b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "ic_cast1_white_24dp.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ic_cast1_white_24dp-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ic_cast1_white_24dp-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-1.png b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-1.png new file mode 100644 index 00000000..090d9226 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-1.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-2.png b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-2.png new file mode 100644 index 00000000..41ed2302 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp-2.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp.png b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp.png new file mode 100644 index 00000000..090d9226 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting1.imageset/ic_cast1_white_24dp.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/Contents.json b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/Contents.json new file mode 100644 index 00000000..84f3f872 --- /dev/null +++ b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "ic_cast2_white_24dp.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ic_cast2_white_24dp-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ic_cast2_white_24dp-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-1.png b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-1.png new file mode 100644 index 00000000..a798a907 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-1.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-2.png b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-2.png new file mode 100644 index 00000000..a49ee68d Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp-2.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp.png b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp.png new file mode 100644 index 00000000..a798a907 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastConnecting2.imageset/ic_cast2_white_24dp.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/Contents.json b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/Contents.json new file mode 100644 index 00000000..23b70ec4 --- /dev/null +++ b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "ic_cast_white_24dp.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ic_cast_white_24dp-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ic_cast_white_24dp-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-1.png b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-1.png new file mode 100644 index 00000000..62c086f1 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-1.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-2.png b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-2.png new file mode 100644 index 00000000..ee414542 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp-2.png differ diff --git a/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp.png b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp.png new file mode 100644 index 00000000..62c086f1 Binary files /dev/null and b/JellyfinPlayer/Assets.xcassets/CastDisconnected.imageset/ic_cast_white_24dp.png differ diff --git a/JellyfinPlayer/JellyfinPlayerApp.swift b/JellyfinPlayer/JellyfinPlayerApp.swift index c5103ef3..3f907a93 100644 --- a/JellyfinPlayer/JellyfinPlayerApp.swift +++ b/JellyfinPlayer/JellyfinPlayerApp.swift @@ -141,24 +141,14 @@ extension View { @main struct JellyfinPlayerApp: App { let persistenceController = PersistenceController.shared - - func test_cast() { - let scanner = CastDeviceScanner() - - NotificationCenter.default.addObserver(forName: CastDeviceScanner.deviceListDidChange, object: scanner, queue: nil) { _ in - dump(scanner.devices) - } - - scanner.startScanning() - } - + var body: some Scene { WindowGroup { SplashView() .environment(\.managedObjectContext, persistenceController.container.viewContext) .withHostingWindow { window in window?.rootViewController = PreferenceUIHostingController(wrappedView: SplashView().environment(\.managedObjectContext, persistenceController.container.viewContext)) - }.onAppear(perform: test_cast) + } } } } diff --git a/JellyfinPlayer/VideoPlayer.storyboard b/JellyfinPlayer/VideoPlayer.storyboard index eefbdb2b..216826d8 100644 --- a/JellyfinPlayer/VideoPlayer.storyboard +++ b/JellyfinPlayer/VideoPlayer.storyboard @@ -110,7 +110,7 @@ @@ -173,6 +187,7 @@ + @@ -196,10 +211,11 @@ - + + diff --git a/JellyfinPlayer/VideoPlayer.swift b/JellyfinPlayer/VideoPlayer.swift index 2f9760a5..2638c616 100644 --- a/JellyfinPlayer/VideoPlayer.swift +++ b/JellyfinPlayer/VideoPlayer.swift @@ -50,7 +50,8 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe @IBOutlet weak var jumpBackButton: UIButton! @IBOutlet weak var jumpForwardButton: UIButton! @IBOutlet weak var playerSettingsButton: UIButton! - + @IBOutlet weak var castButton: UIButton! + var shouldShowLoadingScreen: Bool = false var ssTargetValueOffset: Int = 0 var ssStartValue: Int = 0 @@ -172,7 +173,11 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe self.mainActionButton.setImage(UIImage(systemName: "play"), for: .normal) } } - + + @IBAction func castButtonPressed(_ sender: Any) { + + } + func settingsPopoverDismissed() { optionsVC?.dismiss(animated: true, completion: nil) self.mediaPlayer.play() @@ -273,7 +278,24 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe UIDevice.current.setValue(value, forKey: "orientation") } } + + func mediaHasStartedPlaying() { + let scanner = CastDeviceScanner() + NotificationCenter.default.addObserver(forName: CastDeviceScanner.deviceListDidChange, object: scanner, queue: nil) { _ in + dump(scanner.devices) + if(!scanner.devices.isEmpty) { + self.castButton.isEnabled = true; + self.castButton.setImage(UIImage(named: "CastDisconnected"), for: .normal) + } else { + self.castButton.isEnabled = false; + self.castButton.setImage(nil, for: .normal) + } + } + + scanner.startScanning() + } + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) overrideUserInterfaceStyle = .dark @@ -430,6 +452,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe mediaPlayer.currentVideoSubTitleIndex = selectedCaptionTrack mediaPlayer.pause() mediaPlayer.play() + self.mediaHasStartedPlaying() }) .store(in: &cancellables) }