added example video player in the view

This commit is contained in:
Jens Timmerman 2020-09-25 01:35:12 +02:00
parent 6ca5142e71
commit 8bf0c603b0
4 changed files with 68 additions and 3 deletions

View File

@ -13,6 +13,7 @@
B4F0CC82251BE62F00E9EA74 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4F0CC81251BE62F00E9EA74 /* Preview Assets.xcassets */; };
B4F0CC8D251BE62F00E9EA74 /* vrtnuTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0CC8C251BE62F00E9EA74 /* vrtnuTests.swift */; };
B4F0CC98251BE62F00E9EA74 /* vrtnuUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0CC97251BE62F00E9EA74 /* vrtnuUITests.swift */; };
B4F0CCAA251BFD6F00E9EA74 /* video.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0CCA9251BFD6F00E9EA74 /* video.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -45,6 +46,7 @@
B4F0CC93251BE62F00E9EA74 /* vrtnuUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = vrtnuUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
B4F0CC97251BE62F00E9EA74 /* vrtnuUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = vrtnuUITests.swift; sourceTree = "<group>"; };
B4F0CC99251BE62F00E9EA74 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B4F0CCA9251BFD6F00E9EA74 /* video.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = video.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -100,6 +102,7 @@
B4F0CC7E251BE62F00E9EA74 /* Assets.xcassets */,
B4F0CC83251BE62F00E9EA74 /* Info.plist */,
B4F0CC80251BE62F00E9EA74 /* Preview Content */,
B4F0CCA9251BFD6F00E9EA74 /* video.swift */,
);
path = vrtnu;
sourceTree = "<group>";
@ -261,6 +264,7 @@
files = (
B4F0CC7D251BE62B00E9EA74 /* ContentView.swift in Sources */,
B4F0CC7B251BE62B00E9EA74 /* vrtnuApp.swift in Sources */,
B4F0CCAA251BFD6F00E9EA74 /* video.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -6,14 +6,19 @@
//
import SwiftUI
import AVKit
import AVFoundation
struct ContentView: View {
private let player = AVPlayer(url: URL(string: "https://remix-cf.lwc.vrtcdn.be/remix/ecd69313-4a39-4297-95b1-aede167725b7/remix.ism/.m3u8")!)
var body: some View {
Text("Hello, world!")
.padding()
}
VideoPlayer(player: player)
};
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()

43
vrtnu/vrtnu/video.swift Normal file
View File

@ -0,0 +1,43 @@
//
// video.swift
// vrtnu
//
// Created by Jens Timmerman on 24/09/2020.
//
/*
See LICENSE folder for this samples licensing information.
Abstract:
Video is a simple struct that provides the title, url, and timing information about the app's videos.
*/
//import UIKit
import AVFoundation
struct Video: Hashable {
let hlsUrl: URL
let title: String
let duration: TimeInterval
var resumeTime: TimeInterval
init(hlsUrl: URL, title: String, duration: TimeInterval, resumeTime: TimeInterval = 0) {
self.hlsUrl = hlsUrl
self.title = title
self.duration = duration
self.resumeTime = resumeTime
}
}
extension Video {
static func makeVideos() -> [Video] {
return [
Video(hlsUrl: URL(string: "https://remix-cf.lwc.vrtcdn.be/remix/ecd69313-4a39-4297-95b1-aede167725b7/remix.ism/.m3u8")!,
title: "best of dinges",
duration: 2946),
]
}
}

View File

@ -6,6 +6,7 @@
//
import SwiftUI
import AVFoundation
@main
struct vrtnuApp: App {
@ -14,4 +15,16 @@ struct vrtnuApp: App {
ContentView()
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let audioSession = AVAudioSession.sharedInstance()
do {
try audioSession.setCategory(.playback, mode: .moviePlayback)
}
catch {
print("Setting category to AVAudioSessionCategoryPlayback failed.")
}
return true
}
}