Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftSIQI committed Oct 11, 2023
1 parent 5278ead commit f8f2ea8
Show file tree
Hide file tree
Showing 112 changed files with 3,766 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See LICENSE folder for this sample’s licensing information.
#
# Apple sample code gitignore configuration.

# Finder
.DS_Store

# Xcode - User files
xcuserdata/

**/*.xcodeproj/project.xcworkspace/*
!**/*.xcodeproj/project.xcworkspace/xcshareddata

**/*.xcodeproj/project.xcworkspace/xcshareddata/*
!**/*.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

**/*.playground/playground.xcworkspace/*
!**/*.playground/playground.xcworkspace/xcshareddata

**/*.playground/playground.xcworkspace/xcshareddata/*
!**/*.playground/playground.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
13 changes: 13 additions & 0 deletions Configuration/SampleCode.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// See the LICENSE.txt file for this sample’s licensing information.
//
// SampleCode.xcconfig
//

// The `SAMPLE_CODE_DISAMBIGUATOR` configuration is to make it easier to build
// and run a sample code project. Once you set your project's development team,
// you'll have a unique bundle identifier. This is because the bundle identifier
// is derived based on the 'SAMPLE_CODE_DISAMBIGUATOR' value. Do not use this
// approach in your own projects—it's only useful for sample code projects because
// they are frequently downloaded and don't have a development team set.
SAMPLE_CODE_DISAMBIGUATOR=${DEVELOPMENT_TEAM}
5 changes: 5 additions & 0 deletions DestinationVideo.xcodeproj/.xcodesamplecode.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>
601 changes: 601 additions & 0 deletions DestinationVideo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C4462E7029AAAB2E00E3C854"
BuildableName = "Destination Video.app"
BlueprintName = "DestinationVideo"
ReferencedContainer = "container:DestinationVideo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C4462E7029AAAB2E00E3C854"
BuildableName = "Destination Video.app"
BlueprintName = "DestinationVideo"
ReferencedContainer = "container:DestinationVideo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C4462E7029AAAB2E00E3C854"
BuildableName = "Destination Video.app"
BlueprintName = "DestinationVideo"
ReferencedContainer = "container:DestinationVideo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
45 changes: 45 additions & 0 deletions DestinationVideo/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
A view that presents the app's user interface.
*/

import SwiftUI

// The app uses `LibraryView` as its main UI.
struct ContentView: View {

/// The library's selection path.
@State private var navigationPath = [Video]()
/// A Boolean value that indicates whether the app is currently presenting an immersive space.
@State private var isPresentingSpace = false
/// The app's player model.
@Environment(PlayerModel.self) private var player

var body: some View {
#if os(visionOS)
switch player.presentation {
case .fullWindow:
// Present the player full window and begin playback.
PlayerView()
.onAppear {
player.play()
}
default:
// Show the app's content library by default.
LibraryView(path: $navigationPath, isPresentingSpace: $isPresentingSpace)
}
#else
LibraryView(path: $navigationPath)
// A custom modifier that shows the player in a fullscreen modal presentation in iOS and tvOS.
.fullScreenCoverPlayer(player: player)
#endif
}
}

#Preview {
ContentView()
.environment(PlayerModel())
.environment(VideoLibrary())
}
8 changes: 8 additions & 0 deletions DestinationVideo/DestinationVideo.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.group-session</key>
<true/>
</dict>
</plist>
46 changes: 46 additions & 0 deletions DestinationVideo/DestinationVideo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
The main app structure.
*/

import SwiftUI
import os

@main
struct DestinationVideo: App {

/// An object that controls the video playback behavior.
@State private var player = PlayerModel()
/// An object that manages the library of video content.
@State private var library = VideoLibrary()

var body: some Scene {
// The app's primary content window.
WindowGroup {
ContentView()
.environment(player)
.environment(library)
#if !os(visionOS)
// Use a dark color scheme on supported platforms.
.preferredColorScheme(.dark)
.tint(.white)
#endif
}
#if os(visionOS)
// Defines an immersive space to present a destination in which to watch the video.
ImmersiveSpace(for: Destination.self) { $destination in
if let destination {
DestinationView(destination)
.environment(player)
}
}
// Set the immersion style to progressive, so the user can use the crown to dial in their experience.
.immersionStyle(selection: .constant(.progressive), in: .progressive)
#endif
}
}

/// A global logger for the app.
let logger = Logger()
25 changes: 25 additions & 0 deletions DestinationVideo/Extensions/AVExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
A structure that represents the result of an audio session interruption, such as a phone call.
*/

import AVFoundation

// A simple type that unpacks the relevant values from an AVAudioSession interruption event.
struct InterruptionResult {

let type: AVAudioSession.InterruptionType
let options: AVAudioSession.InterruptionOptions

init?(_ notification: Notification) {
// Determine the interruption type and options.
guard let type = notification.userInfo?[AVAudioSessionInterruptionTypeKey] as? AVAudioSession.InterruptionType,
let options = notification.userInfo?[AVAudioSessionInterruptionOptionKey] as? AVAudioSession.InterruptionOptions else {
return nil
}
self.type = type
self.options = options
}
}
59 changes: 59 additions & 0 deletions DestinationVideo/Extensions/ViewExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
Helper extensions to simplify multiplatform development.
*/

import SwiftUI
import UIKit

extension View {

/// A helper function that returns a platform-specific value.
func valueFor<V>(iOS: V, tvOS: V, visionOS: V) -> V {
#if os(visionOS)
visionOS
#elseif os(tvOS)
tvOS
#else
iOS
#endif
}

/// A Boolean value that indicates whether the current platform is visionOS.
///
/// If the value is `true`, `isMobile` is also true.
var isVision: Bool {
#if os(visionOS)
true
#else
false
#endif
}

/// A Boolean value that indicates whether the current platform is iOS or iPadOS.
var isMobile: Bool {
#if os(iOS)
true
#else
false
#endif
}

/// A Boolean value that indicates whether the current platform is tvOS.
var isTV: Bool {
#if os(tvOS)
true
#else
false
#endif
}

/// A debugging function to add a border around a view.
func debugBorder(color: Color = .red, width: CGFloat = 1.0, opacity: CGFloat = 1.0) -> some View {
self
.border(color, width: width)
.opacity(opacity)
}
}
10 changes: 10 additions & 0 deletions DestinationVideo/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
</dict>
</plist>
37 changes: 37 additions & 0 deletions DestinationVideo/Model/Destination.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
See the LICENSE.txt file for this sample’s licensing information.
Abstract:
Constants that define named destinations the app supports.
*/

import Foundation

enum Destination: String, CaseIterable, Identifiable, Codable {

case beach
case camping
case creek
case hillside
case lake
case ocean
case park

var id: Self { self }

/// The environment image to load.
var imageName: String { "\(rawValue)_scene" }

/// A number of degrees to rotate the 360 "destination" image to provide the best initial view.
var rotationDegrees: Double {
switch self {
case .beach: 55
case .camping: -55
case .creek: 0
case .hillside: 0
case .lake: -55
case .ocean: 0
case .park: 190
}
}
}
Loading

0 comments on commit f8f2ea8

Please sign in to comment.