Skip to content

Commit 8f0daa2

Browse files
committed
feat - #13 Video Player UI
Video Player, 'Pause/Play' Button
1 parent 83d2070 commit 8f0daa2

File tree

11 files changed

+208
-2
lines changed

11 files changed

+208
-2
lines changed

.DS_Store

8 KB
Binary file not shown.

HomeCamProject/.DS_Store

2 KB
Binary file not shown.

HomeCamProject/HomeCamProject.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
91B8B0352CF8454F00365904 /* fire_detection.grpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91B8B0322CF8454F00365904 /* fire_detection.grpc.swift */; };
1919
91B8B0362CF8454F00365904 /* fire_detection.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91B8B0332CF8454F00365904 /* fire_detection.pb.swift */; };
2020
91B8B03B2CF85D5400365904 /* sample.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 91B8B03A2CF85D5400365904 /* sample.mp4 */; };
21+
D61122132CFA9BE20040AD8C /* VideoContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61122122CFA9BE20040AD8C /* VideoContentView.swift */; };
2122
/* End PBXBuildFile section */
2223

2324
/* Begin PBXFileReference section */
@@ -30,6 +31,7 @@
3031
91B8B0322CF8454F00365904 /* fire_detection.grpc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = fire_detection.grpc.swift; sourceTree = "<group>"; };
3132
91B8B0332CF8454F00365904 /* fire_detection.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = fire_detection.pb.swift; sourceTree = "<group>"; };
3233
91B8B03A2CF85D5400365904 /* sample.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = sample.mp4; sourceTree = "<group>"; };
34+
D61122122CFA9BE20040AD8C /* VideoContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoContentView.swift; sourceTree = "<group>"; };
3335
/* End PBXFileReference section */
3436

3537
/* Begin PBXFrameworksBuildPhase section */
@@ -69,6 +71,7 @@
6971
91B2911F2CF81CD60035D87D /* HomeCamProjectApp.swift */,
7072
91B291212CF81CD60035D87D /* ContentView.swift */,
7173
91B8B0302CF83D9200365904 /* ConnectView.swift */,
74+
D61122122CFA9BE20040AD8C /* VideoContentView.swift */,
7275
91B291232CF81CD80035D87D /* Assets.xcassets */,
7376
91B8B03A2CF85D5400365904 /* sample.mp4 */,
7477
91B291252CF81CD80035D87D /* Preview Content */,
@@ -177,6 +180,7 @@
177180
91B291222CF81CD60035D87D /* ContentView.swift in Sources */,
178181
91B8B0352CF8454F00365904 /* fire_detection.grpc.swift in Sources */,
179182
91B291202CF81CD60035D87D /* HomeCamProjectApp.swift in Sources */,
183+
D61122132CFA9BE20040AD8C /* VideoContentView.swift in Sources */,
180184
91B8B0362CF8454F00365904 /* fire_detection.pb.swift in Sources */,
181185
);
182186
runOnlyForDeploymentPostprocessing = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"originHash" : "b0d8975aa19f1bb7106ae78f24de3911e84189892afc3b6fe6db19bcec9e631c",
3+
"pins" : [
4+
{
5+
"identity" : "grpc-swift",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/grpc/grpc-swift.git",
8+
"state" : {
9+
"revision" : "8c5e99d0255c373e0330730d191a3423c57373fb",
10+
"version" : "1.24.2"
11+
}
12+
},
13+
{
14+
"identity" : "swift-atomics",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/apple/swift-atomics.git",
17+
"state" : {
18+
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
19+
"version" : "1.2.0"
20+
}
21+
},
22+
{
23+
"identity" : "swift-collections",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/apple/swift-collections.git",
26+
"state" : {
27+
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
28+
"version" : "1.1.4"
29+
}
30+
},
31+
{
32+
"identity" : "swift-http-types",
33+
"kind" : "remoteSourceControl",
34+
"location" : "https://github.com/apple/swift-http-types",
35+
"state" : {
36+
"revision" : "ef18d829e8b92d731ad27bb81583edd2094d1ce3",
37+
"version" : "1.3.1"
38+
}
39+
},
40+
{
41+
"identity" : "swift-log",
42+
"kind" : "remoteSourceControl",
43+
"location" : "https://github.com/apple/swift-log.git",
44+
"state" : {
45+
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
46+
"version" : "1.6.2"
47+
}
48+
},
49+
{
50+
"identity" : "swift-nio",
51+
"kind" : "remoteSourceControl",
52+
"location" : "https://github.com/apple/swift-nio.git",
53+
"state" : {
54+
"revision" : "dca6594f65308c761a9c409e09fbf35f48d50d34",
55+
"version" : "2.77.0"
56+
}
57+
},
58+
{
59+
"identity" : "swift-nio-extras",
60+
"kind" : "remoteSourceControl",
61+
"location" : "https://github.com/apple/swift-nio-extras.git",
62+
"state" : {
63+
"revision" : "2e9746cfc57554f70b650b021b6ae4738abef3e6",
64+
"version" : "1.24.1"
65+
}
66+
},
67+
{
68+
"identity" : "swift-nio-http2",
69+
"kind" : "remoteSourceControl",
70+
"location" : "https://github.com/apple/swift-nio-http2.git",
71+
"state" : {
72+
"revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca",
73+
"version" : "1.34.1"
74+
}
75+
},
76+
{
77+
"identity" : "swift-nio-ssl",
78+
"kind" : "remoteSourceControl",
79+
"location" : "https://github.com/apple/swift-nio-ssl.git",
80+
"state" : {
81+
"revision" : "c7e95421334b1068490b5d41314a50e70bab23d1",
82+
"version" : "2.29.0"
83+
}
84+
},
85+
{
86+
"identity" : "swift-nio-transport-services",
87+
"kind" : "remoteSourceControl",
88+
"location" : "https://github.com/apple/swift-nio-transport-services.git",
89+
"state" : {
90+
"revision" : "bbd5e63cf949b7db0c9edaf7a21e141c52afe214",
91+
"version" : "1.23.0"
92+
}
93+
},
94+
{
95+
"identity" : "swift-protobuf",
96+
"kind" : "remoteSourceControl",
97+
"location" : "https://github.com/apple/swift-protobuf.git",
98+
"state" : {
99+
"revision" : "ebc7251dd5b37f627c93698e4374084d98409633",
100+
"version" : "1.28.2"
101+
}
102+
},
103+
{
104+
"identity" : "swift-system",
105+
"kind" : "remoteSourceControl",
106+
"location" : "https://github.com/apple/swift-system.git",
107+
"state" : {
108+
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168",
109+
"version" : "1.4.0"
110+
}
111+
}
112+
],
113+
"version" : 3
114+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>HomeCamProject.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>
0 Bytes
Binary file not shown.

HomeCamProject/HomeCamProject/HomeCamProjectApp.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import GRPC
1212
struct HomeCamProjectApp: App {
1313
var body: some Scene {
1414
WindowGroup {
15-
// ContentView()
16-
ConnectView()
15+
VideoContentView()
1716
}
1817
}
1918
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//
2+
// VideoContentView.swift
3+
// HomeCamProject
4+
//
5+
// Created by HanJW on 11/30/24.
6+
//
7+
8+
import SwiftUI
9+
import AVKit
10+
import AVFoundation
11+
12+
struct VideoPlayerView: UIViewControllerRepresentable {
13+
let player: AVPlayer
14+
15+
func makeUIViewController(context: Context) -> AVPlayerViewController {
16+
let controller = AVPlayerViewController()
17+
controller.player = player
18+
return controller
19+
}
20+
21+
func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {}
22+
}
23+
24+
struct VideoContentView: View {
25+
@State private var player: AVPlayer
26+
27+
init() {
28+
let url = Bundle.main.url(forResource: "sample", withExtension: "mp4")!
29+
_player = State(initialValue: AVPlayer(url: url))
30+
}
31+
32+
var body: some View {
33+
VStack {
34+
VideoPlayerView(player: player)
35+
.frame(height: 300)
36+
.onAppear {
37+
player.play()
38+
}
39+
40+
ControlView(player: player)
41+
}
42+
}
43+
}
44+
45+
struct ControlView: View {
46+
@State private var isPlaying = false
47+
let player: AVPlayer
48+
49+
var body: some View {
50+
HStack {
51+
Button(action: {
52+
if isPlaying {
53+
player.pause()
54+
} else {
55+
player.play()
56+
}
57+
isPlaying.toggle()
58+
}) {
59+
Image(systemName: isPlaying ? "pause" : "play")
60+
.resizable()
61+
.frame(width: 25, height: 25)
62+
}
63+
}
64+
}
65+
}
66+
67+
struct PlayerContentView: View {
68+
var body: some View {
69+
VideoContentView()
70+
}
71+
}
72+
73+
#Preview {
74+
VideoContentView()
75+
}

server/.DS_Store

6 KB
Binary file not shown.

server/cmd/.DS_Store

6 KB
Binary file not shown.

0 commit comments

Comments
 (0)