I have created a simple AVPlayer. (If I didn't create it correctly, please help me fixing it... ) I want to display it in my VStack with swift ui, but I'm kind of stuck...
If at least there was the AVPlayer View component in the library, it would have been easier, but I didn't found it in the library...
Here is my code in the ContentView.swift
:
//
// ContentView.swift
// test
//
// Created by Francis Dolbec on 2019-06-26.
// Copyright © 2019 Francis Dolbec. All rights reserved.
//
import SwiftUI
import AVKit
import AVFoundation
// MARK: variables
var hauteurMenuBar = NSApplication.shared.mainMenu?.menuBarHeight
var urlVideo = URL(string: "/Users/francisdolbec/Movies/Séries Télé/Rick et Morty/Rick.and.Morty.S01E01.VFQ.HDTV.1080p.x264-Kamek.mp4")
let player = AVPlayer(url: urlVideo!)
struct ContentView : View {
var body: some View {
VStack {
Text("Hello World")
.frame(maxWidth: .infinity, maxHeight: .infinity)
Text("PATATE!")
//player.play()
}
.frame(minWidth: 1024, idealWidth: 1440, maxWidth: .infinity, minHeight: (640-hauteurMenuBar!), idealHeight: (900-hauteurMenuBar!), maxHeight: .infinity)
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
By the way, if there's a tutorial that show how to make a video player with swift ui, I would really appreciate it!
EDIT I forgot to say that I am developing a macOS app.