From 32bdebc898b9b4d04e03194f46cbeeffc5db4ca8 Mon Sep 17 00:00:00 2001 From: zztkm Date: Wed, 2 Oct 2024 18:30:13 +0900 Subject: [PATCH] =?UTF-8?q?Binding=20=E5=A4=89=E6=95=B0=E3=81=AE=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E6=96=B9=E6=B3=95=E3=82=92=E6=94=B9=E3=82=81=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sora/SwiftUIVideoView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sora/SwiftUIVideoView.swift b/Sora/SwiftUIVideoView.swift index 031f3822..de6c4a5d 100644 --- a/Sora/SwiftUIVideoView.swift +++ b/Sora/SwiftUIVideoView.swift @@ -11,7 +11,7 @@ public struct SwiftUIVideoView: View where Background: View { // TODO(zztkm): わかりやすいコメントを書く // 親 View で定義された stopVideo 変数と接続するための変数 - @Binding private var stopVideo: Bool? + @Binding private var stopVideo: Bool @ObservedObject private var controller: VideoController @@ -30,10 +30,10 @@ public struct SwiftUIVideoView: View where Background: View { - parameter stream: 描画される映像ストリーム nil の場合は何も描画されません - paramater background: 映像のクリア時に表示する背景ビュー */ - public init(_ stream: MediaStream?, background: Background, stopVideo: Binding?) { + public init(_ stream: MediaStream?, background: Background, stopVideo: Binding? = nil) { self.stream = stream self.background = background - self._stopVideo = stopVideo + self._stopVideo = stopVideo ?? .constant(false) // 指定がない場合は固定値 false を与える controller = VideoController(stream: stream) } @@ -46,7 +46,7 @@ public struct SwiftUIVideoView: View where Background: View { .opacity(controller.isCleared ? 0 : 1) } .onChange(of: stopVideo, initial: true) { newValue in - videoStop(newValue) + self.videoStop(newValue) } }