Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created July 13, 2024 19:38
Show Gist options
  • Save amosgyamfi/b8f9c39f5de94907db0b3c1b62e29adb to your computer and use it in GitHub Desktop.
Save amosgyamfi/b8f9c39f5de94907db0b3c1b62e29adb to your computer and use it in GitHub Desktop.
//
// 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