Created
July 13, 2024 19:38
-
-
Save amosgyamfi/b8f9c39f5de94907db0b3c1b62e29adb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// VideoPlayerView.swift | |
// OpenvisionOS | |
// | |
// Created by Amos Gyamfi on 7.2.2024. | |
// | |
import SwiftUI | |
import AVKit | |
struct VideoPlayerView: View { | |
@State var amosPlayer = AVPlayer(url: Bundle.main.url(forResource: "TikTokCloneShortFinal1", withExtension: "mp4")!) | |
@State var isPlaying = false | |
@State var isMuted = false | |
var body: some View { | |
NavigationStack { | |
ZStack { | |
VideoPlayer(player: amosPlayer) | |
} | |
.toolbar { | |
ToolbarItem(placement: .bottomOrnament) { | |
/* Button { | |
isPlaying ? amosPlayer.pause() : amosPlayer.play() | |
isPlaying.toggle() | |
amosPlayer.seek(to: .zero) | |
} label: { | |
Image(systemName: isPlaying ? "pause.fill" : "play.fill") | |
.font(.largeTitle) | |
.bold() | |
.padding() | |
.contentTransition(.symbolEffect) | |
}*/ | |
Button{ | |
isMuted.toggle() | |
amosPlayer.isMuted = isMuted | |
} label: { | |
Image(systemName: isMuted ? "speaker.slash.fill" : "speaker.fill") | |
.font(.largeTitle) | |
.bold() | |
.padding() | |
.contentTransition(.symbolEffect) | |
} | |
} | |
} | |
} | |
} | |
} | |
#Preview { | |
VideoPlayerView() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment