mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix video stream playback
This commit is contained in:
parent
9c7dc185fe
commit
e92f83504a
@ -703,7 +703,7 @@ public final class MediaStreamComponent: CombinedComponent {
|
|||||||
topInset: environment.statusBarHeight,
|
topInset: environment.statusBarHeight,
|
||||||
sideInset: environment.safeInsets.left,
|
sideInset: environment.safeInsets.left,
|
||||||
leftItem: AnyComponent(Button(
|
leftItem: AnyComponent(Button(
|
||||||
content: AnyComponent(NavigationBackButtonComponent(text: environment.strings.Common_Close, color: .white)),
|
content: AnyComponent(Text(text: environment.strings.Common_Close, font: Font.regular(17.0), color: .white)),
|
||||||
action: { [weak call] in
|
action: { [weak call] in
|
||||||
let _ = call?.leave(terminateIfPossible: false)
|
let _ = call?.leave(terminateIfPossible: false)
|
||||||
})
|
})
|
||||||
|
@ -44,7 +44,7 @@ final class MediaStreamVideoComponent: Component {
|
|||||||
return State()
|
return State()
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class View: UIView, AVPictureInPictureControllerDelegate, AVPictureInPictureSampleBufferPlaybackDelegate, ComponentTaggedView {
|
public final class View: UIView, AVPictureInPictureControllerDelegate, ComponentTaggedView {
|
||||||
public final class Tag {
|
public final class Tag {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,32 @@ final class MediaStreamVideoComponent: Component {
|
|||||||
self.addSubview(videoView)
|
self.addSubview(videoView)
|
||||||
|
|
||||||
if #available(iOSApplicationExtension 15.0, iOS 15.0, *), AVPictureInPictureController.isPictureInPictureSupported(), let sampleBufferVideoView = videoView as? SampleBufferVideoRenderingView {
|
if #available(iOSApplicationExtension 15.0, iOS 15.0, *), AVPictureInPictureController.isPictureInPictureSupported(), let sampleBufferVideoView = videoView as? SampleBufferVideoRenderingView {
|
||||||
let pictureInPictureController = AVPictureInPictureController(contentSource: AVPictureInPictureController.ContentSource(sampleBufferDisplayLayer: sampleBufferVideoView.sampleBufferLayer, playbackDelegate: self))
|
final class PlaybackDelegateImpl: NSObject, AVPictureInPictureSampleBufferPlaybackDelegate {
|
||||||
|
func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func pictureInPictureControllerTimeRangeForPlayback(_ pictureInPictureController: AVPictureInPictureController) -> CMTimeRange {
|
||||||
|
return CMTimeRange(start: .zero, duration: .positiveInfinity)
|
||||||
|
}
|
||||||
|
|
||||||
|
func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, didTransitionToRenderSize newRenderSize: CMVideoDimensions) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, skipByInterval skipInterval: CMTime, completion completionHandler: @escaping () -> Void) {
|
||||||
|
completionHandler()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func pictureInPictureControllerShouldProhibitBackgroundAudioPlayback(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let pictureInPictureController = AVPictureInPictureController(contentSource: AVPictureInPictureController.ContentSource(sampleBufferDisplayLayer: sampleBufferVideoView.sampleBufferLayer, playbackDelegate: PlaybackDelegateImpl()))
|
||||||
|
|
||||||
pictureInPictureController.delegate = self
|
pictureInPictureController.delegate = self
|
||||||
pictureInPictureController.canStartPictureInPictureAutomaticallyFromInline = true
|
pictureInPictureController.canStartPictureInPictureAutomaticallyFromInline = true
|
||||||
@ -193,28 +218,6 @@ final class MediaStreamVideoComponent: Component {
|
|||||||
return availableSize
|
return availableSize
|
||||||
}
|
}
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureControllerTimeRangeForPlayback(_ pictureInPictureController: AVPictureInPictureController) -> CMTimeRange {
|
|
||||||
return CMTimeRange(start: .zero, duration: .positiveInfinity)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, didTransitionToRenderSize newRenderSize: CMVideoDimensions) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, skipByInterval skipInterval: CMTime, completion completionHandler: @escaping () -> Void) {
|
|
||||||
completionHandler()
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureControllerShouldProhibitBackgroundAudioPlayback(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
|
public func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
|
||||||
guard let component = self.component else {
|
guard let component = self.component else {
|
||||||
completionHandler(false)
|
completionHandler(false)
|
||||||
@ -226,7 +229,7 @@ final class MediaStreamVideoComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pictureInPictureControllerWillStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
func pictureInPictureControllerDidStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||||
self.state?.updated(transition: .immediate)
|
self.state?.updated(transition: .immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,6 +697,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.updateIsAudioSessionActive(false)
|
strongSelf.updateIsAudioSessionActive(false)
|
||||||
strongSelf.updateSessionState(internalState: strongSelf.internalState, audioSessionControl: nil)
|
strongSelf.updateSessionState(internalState: strongSelf.internalState, audioSessionControl: nil)
|
||||||
|
|
||||||
|
if strongSelf.isStream {
|
||||||
|
let _ = strongSelf.leave(terminateIfPossible: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
subscriber.putCompletion()
|
subscriber.putCompletion()
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d389503ac99d5d6fa16870cc280e83151cba8ccc
|
Subproject commit 5dfa5925449e5279ba7e1b0a401b0678dea86dcc
|
Loading…
x
Reference in New Issue
Block a user