Skip to content

Commit ca2d9df

Browse files
committed
Add VideoPlayer bound to a media URL
1 parent 1329f7d commit ca2d9df

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// VideoPlayer.swift
3+
// AndroidSwiftUICore
4+
//
5+
// A video player with system playback controls. The node carries the media
6+
// URL; the Android interpreter hosts a platform player view, and the desktop
7+
// rig shows a placeholder.
8+
//
9+
10+
import Foundation
11+
12+
/// A playable media item. Mirrors the AVKit spelling; only URL-backed
13+
/// playback is modeled.
14+
public struct AVPlayer: Sendable {
15+
public var url: URL
16+
public init(url: URL) { self.url = url }
17+
}
18+
19+
public struct VideoPlayer: View {
20+
21+
internal let player: AVPlayer
22+
23+
public init(player: AVPlayer) {
24+
self.player = player
25+
}
26+
27+
public typealias Body = Never
28+
}
29+
30+
extension VideoPlayer: PrimitiveView {
31+
public func _render(in context: ResolveContext) -> RenderNode {
32+
RenderNode(
33+
type: "VideoPlayer",
34+
id: context.path,
35+
props: ["url": .string(player.url.absoluteString)]
36+
)
37+
}
38+
}

0 commit comments

Comments
 (0)