Skip to content

Commit

Permalink
Add support for visionOS
Browse files Browse the repository at this point in the history
- Introduced a versioned Package.swift as per [specification](https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md\#version-specific-manifest-selection)
- Added `.visionOS` as a supported platform
- Updated handling of the background mode of AVPlayer for visionOS
- Disabled `ImageDecoders.Video` as `AVAssetImageGenerator.copyCGImage` is not available for visionOS
  • Loading branch information
bobek-balinek committed Dec 25, 2023
1 parent 1694798 commit 0cb9a53
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -7,7 +7,8 @@ let package = Package(
.iOS(.v13),
.tvOS(.v13),
.macOS(.v10_15),
.watchOS(.v6)
.watchOS(.v6),
.visionOS(.v1),
],
products: [
.library(name: "Nuke", targets: ["Nuke"]),
Expand Down
24 changes: 24 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "Nuke",
platforms: [
.iOS(.v13),
.tvOS(.v13),
.macOS(.v10_15),
.watchOS(.v6)
],
products: [
.library(name: "Nuke", targets: ["Nuke"]),
.library(name: "NukeUI", targets: ["NukeUI"]),
.library(name: "NukeVideo", targets: ["NukeVideo"]),
.library(name: "NukeExtensions", targets: ["NukeExtensions"])
],
targets: [
.target(name: "Nuke"),
.target(name: "NukeUI", dependencies: ["Nuke"]),
.target(name: "NukeVideo", dependencies: ["Nuke"]),
.target(name: "NukeExtensions", dependencies: ["Nuke"])
]
)
2 changes: 1 addition & 1 deletion Sources/NukeVideo/ImageDecoders+Video.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Copyright (c) 2015-2023 Alexander Grebenyuk (github.com/kean).

#if !os(watchOS)
#if !os(watchOS) && !os(visionOS)

import Foundation
import AVKit
Expand Down
6 changes: 5 additions & 1 deletion Sources/NukeVideo/VideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ public final class VideoPlayerView: _PlatformBaseView {
let playerItem = AVPlayerItem(asset: asset)
let player = AVQueuePlayer(playerItem: playerItem)
player.isMuted = true
player.preventsDisplaySleepDuringVideoPlayback = false
#if os(visionOS)
player.preventsAutomaticBackgroundingDuringVideoPlayback = false
#else
player.preventsDisplaySleepDuringVideoPlayback = false
#endif
player.actionAtItemEnd = isLooping ? .none : .pause
self.player = player

Expand Down

0 comments on commit 0cb9a53

Please sign in to comment.