mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-04 03:32:22 +00:00
feat(player): add Apple TV remote play/pause and AirPlay support
- Add playPause event handling in useRemoteControl hook - Configure AVAudioSession for tvOS with longFormAudio policy - Add AVInitialRouteSharingPolicy to enable AirPlay suggestions
This commit is contained in:
3
app.json
3
app.json
@@ -23,7 +23,8 @@
|
||||
},
|
||||
"UISupportsTrueScreenSizeOnMac": true,
|
||||
"UIFileSharingEnabled": true,
|
||||
"LSSupportsOpeningDocumentsInPlace": true
|
||||
"LSSupportsOpeningDocumentsInPlace": true,
|
||||
"AVInitialRouteSharingPolicy": "LongFormAudio"
|
||||
},
|
||||
"config": {
|
||||
"usesNonExemptEncryption": false
|
||||
|
||||
@@ -107,6 +107,7 @@ export function useRemoteControl({
|
||||
updateTime(updated);
|
||||
break;
|
||||
}
|
||||
case "playPause":
|
||||
case "select": {
|
||||
if (isRemoteScrubbing.value && remoteScrubProgress.value != null) {
|
||||
progress.value = remoteScrubProgress.value;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import AVFAudio
|
||||
import AVFoundation
|
||||
import CoreMedia
|
||||
import ExpoModulesCore
|
||||
@@ -63,6 +64,7 @@ class MpvPlayerView: ExpoView {
|
||||
private func setupView() {
|
||||
clipsToBounds = true
|
||||
backgroundColor = .black
|
||||
configureAudioSession()
|
||||
|
||||
videoContainer = UIView()
|
||||
videoContainer.translatesAutoresizingMaskIntoConstraints = false
|
||||
@@ -111,6 +113,21 @@ class MpvPlayerView: ExpoView {
|
||||
CATransaction.commit()
|
||||
}
|
||||
|
||||
private func configureAudioSession() {
|
||||
let audioSession = AVAudioSession.sharedInstance()
|
||||
do {
|
||||
try audioSession.setCategory(
|
||||
.playback,
|
||||
mode: .moviePlayback,
|
||||
policy: .longFormAudio,
|
||||
options: []
|
||||
)
|
||||
try audioSession.setActive(true)
|
||||
} catch {
|
||||
print("Failed to configure audio session: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func loadVideo(config: VideoLoadConfig) {
|
||||
// Skip reload if same URL is already playing
|
||||
if currentURL == config.url {
|
||||
|
||||
Reference in New Issue
Block a user