Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
fix tvOS demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cxfksword committed Apr 23, 2024
1 parent f646e4b commit 53687a8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
12 changes: 8 additions & 4 deletions Demo/Demo-tvOS/Demo-tvOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@
objects = {

/* Begin PBXBuildFile section */
F4D8D7962BD7553E00246C75 /* MPVMetalPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D8D7952BD7553E00246C75 /* MPVMetalPlayerView.swift */; };
F4D8D7982BD7559700246C75 /* MetalLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D8D7972BD7559700246C75 /* MetalLayer.swift */; };
F4EB5D162B61E45000486E3F /* Demo_tvOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D152B61E45000486E3F /* Demo_tvOSApp.swift */; };
F4EB5D182B61E45000486E3F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D172B61E45000486E3F /* ContentView.swift */; };
F4EB5D1A2B61E45200486E3F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4EB5D192B61E45200486E3F /* Assets.xcassets */; };
F4EB5D1D2B61E45200486E3F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F4EB5D1C2B61E45200486E3F /* Preview Assets.xcassets */; };
F4EB5D292B61E48A00486E3F /* MPVMetalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D242B61E48A00486E3F /* MPVMetalViewController.swift */; };
F4EB5D2A2B61E48A00486E3F /* MPVViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D252B61E48A00486E3F /* MPVViewController.swift */; };
F4EB5D2B2B61E48A00486E3F /* MPVMetalPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D262B61E48A00486E3F /* MPVMetalPlayerView.swift */; };
F4EB5D2C2B61E48A00486E3F /* MPVPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D272B61E48A00486E3F /* MPVPlayerView.swift */; };
F4EB5D2D2B61E48A00486E3F /* MPVOGLView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4EB5D282B61E48A00486E3F /* MPVOGLView.swift */; };
F4EB5D302B61E4E700486E3F /* MPVKit in Frameworks */ = {isa = PBXBuildFile; productRef = F4EB5D2F2B61E4E700486E3F /* MPVKit */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
F4D8D7952BD7553E00246C75 /* MPVMetalPlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MPVMetalPlayerView.swift; sourceTree = "<group>"; };
F4D8D7972BD7559700246C75 /* MetalLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetalLayer.swift; sourceTree = "<group>"; };
F4EB5D122B61E45000486E3F /* Demo-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Demo-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
F4EB5D152B61E45000486E3F /* Demo_tvOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Demo_tvOSApp.swift; sourceTree = "<group>"; };
F4EB5D172B61E45000486E3F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
F4EB5D192B61E45200486E3F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
F4EB5D1C2B61E45200486E3F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
F4EB5D242B61E48A00486E3F /* MPVMetalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MPVMetalViewController.swift; sourceTree = "<group>"; };
F4EB5D252B61E48A00486E3F /* MPVViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MPVViewController.swift; sourceTree = "<group>"; };
F4EB5D262B61E48A00486E3F /* MPVMetalPlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MPVMetalPlayerView.swift; path = "../New Group/MPVMetalPlayerView.swift"; sourceTree = "<group>"; };
F4EB5D272B61E48A00486E3F /* MPVPlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MPVPlayerView.swift; sourceTree = "<group>"; };
F4EB5D282B61E48A00486E3F /* MPVOGLView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MPVOGLView.swift; sourceTree = "<group>"; };
F4EB5D312B61E50B00486E3F /* MPVKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = MPVKit; path = ../..; sourceTree = "<group>"; };
Expand Down Expand Up @@ -58,8 +60,9 @@
F4BA11AC2BCCFE3A00B472DE /* Metal */ = {
isa = PBXGroup;
children = (
F4D8D7952BD7553E00246C75 /* MPVMetalPlayerView.swift */,
F4EB5D242B61E48A00486E3F /* MPVMetalViewController.swift */,
F4EB5D262B61E48A00486E3F /* MPVMetalPlayerView.swift */,
F4D8D7972BD7559700246C75 /* MetalLayer.swift */,
);
path = Metal;
sourceTree = "<group>";
Expand Down Expand Up @@ -187,10 +190,11 @@
buildActionMask = 2147483647;
files = (
F4EB5D2A2B61E48A00486E3F /* MPVViewController.swift in Sources */,
F4D8D7962BD7553E00246C75 /* MPVMetalPlayerView.swift in Sources */,
F4EB5D292B61E48A00486E3F /* MPVMetalViewController.swift in Sources */,
F4D8D7982BD7559700246C75 /* MetalLayer.swift in Sources */,
F4EB5D182B61E45000486E3F /* ContentView.swift in Sources */,
F4EB5D162B61E45000486E3F /* Demo_tvOSApp.swift in Sources */,
F4EB5D2B2B61E48A00486E3F /* MPVMetalPlayerView.swift in Sources */,
F4EB5D2D2B61E48A00486E3F /* MPVOGLView.swift in Sources */,
F4EB5D2C2B61E48A00486E3F /* MPVPlayerView.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MPVKit
// warning: metal API validation has been disabled to ignore crash when playing HDR videos.
// Edit Scheme -> Run -> Diagnostics -> Metal API Validation -> Turn it off
final class MPVMetalViewController: UIViewController {
var metalLayer = CAMetalLayer()
var metalLayer = MetalLayer()
var mpv: OpaquePointer!
lazy var queue = DispatchQueue(label: "mpv", qos: .userInitiated)

Expand Down
17 changes: 17 additions & 0 deletions Demo/Demo-tvOS/Demo-tvOS/Player/Metal/MetalLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation
import UIKit

// workaround for MoltenVK problem that causes flicker
// https://github.com/mpv-player/mpv/pull/13651
class MetalLayer: CAMetalLayer {
// workaround for a MoltenVK workaround that sets the drawableSize to 1x1 to forcefully complete
// the presentation, this causes flicker and the drawableSize possibly staying at 1x1
override var drawableSize: CGSize {
get { return super.drawableSize }
set {
if Int(newValue.width) > 1 && Int(newValue.height) > 1 {
super.drawableSize = newValue
}
}
}
}

0 comments on commit 53687a8

Please sign in to comment.