tvOS is the operating system for Apple TV.

Posts under tvOS tag

117 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How to ensure current SKScene has fully loaded before engaging it with the GamePad Controller?
How to ensure current SKScene has fully loaded before engaging it with the GamePad Controller? The problem is this = when stopping sound is involved when I do switch SKScenes, if I press the buttons of the GamePad Controller (which cycle thru these other SKScenes) too fast, the movement of the Game Pieces fails to resume when I return to the Game Scene after the above cycling. This problem occurs only with the os(tvOS) version, but not with the iPad version. And the reason for this distinction is that each SKScene for the iPad has to fully load due to the fact that the button I press to switch SKScenes is at the top-left corner of the iPad -- so, by definition, by the time I have access to this button, the current SKScene has fully loaded. By definition, there is no such button for os(tvOS). Given this button’s absence, I believe I need the Swift version of jQuery’s $(document).ready (function() {. Any help will be appreciated to the rafters ...
1
0
67
1d
How to ensure current SKScene has fully loaded before engaging it with the GamePad Controller?
How to ensure current SKScene has fully loaded before engaging it with the GamePad Controller? MAJOR REWRITE FOR THE SAKE OF HOPEFULLY (?) INCREASED CLARITY The problem is this = when stopping sound is involved when I do switch SKScenes, if I press the buttons of the GamePad Controller (which cycle thru these other SKScenes) too fast, the movement of the Game Pieces fails to resume when I return to the Game Scene after the above cycling. This problem occurs only with the os(tvOS) version, but not with the iPad version. And the reason for this distinction is that each SKScene for the iPad has to fully load due to the fact that the button I press to switch SKScenes is at the top-left corner of the iPad -- so, by definition, by the time I have access to this button, the current SKScene has fully loaded. By definition, there is no such button for os(iOS). Given this button’s absence, I need the Swift version of jQuery’s $(document).ready (function() {. Any help will be appreciated to the rafters ...
1
0
61
1d
AppleTV Simulator SiriRemote not working in App
Hi, I'm having a small App in the AppleTV-Simulator which is supposed to use the Siri-Remotes Swipe-Gesture. It works perfect on the real device but on the simulator the Swipe-Gesture is not recognized in the App but it works on the Start-Screen of the Simulator using the simulated Siri-Remote app. Here is the code which sets up the xAxis ans yAxis value change handlers: #if targetEnvironment(simulator) // Simulator let siriRemote = GCController.controllers().filter { controller in if controller.vendorName == "Gamepad" { return true } else { return false } } let sController = siriRemote.first! let inputProfile = sController.physicalInputProfile let dPad = inputProfile.dpads["Direction Pad"] self.dPad = dPad self.dPad!.xAxis.valueChangedHandler = self.directionPadXAxisValueChangeHandler self.dPad!.yAxis.valueChangedHandler = self.directionPadYAxisValueChangeHandler } #else // Device if let _ = ( notification.object as? GCController)?.microGamepad { let microProfileController = notification.object as! GCController self.microGamePad = microProfileController.microGamepad self.dPad = self.microGamePad!.dpad self.dPad!.xAxis.valueChangedHandler = self.directionPadXAxisValueChangeHandler self.dPad!.yAxis.valueChangedHandler = self.directionPadYAxisValueChangeHandler } #endif Any help is greatly appreciated. Cheers, Frank
0
0
112
1w
How to customise text field? tvOS
I'd like to customise text fields in my application, but I don't see any options for it. When I click text field, new window opens. And there is no title or description. But there must be something that allows me to customize it, right? Apple applications contain customised text fields. This is apple's text field (after clicking on it) This is my text field (after clicking on it) Here is my code: Form { //... TextField("", text: $address) //... } And there is one more problem. After filling this TextField I click enter and it immediately opens the next TextField. I don't want this behaviour.
1
1
130
2w
tvOS Context Menu on LazyVGrid is selecting item below.
Context menu on tvOS LazyVGrid selecting wrong item. It works fine if selecting items on last row. Testing on code from https://developer.apple.com/videos/play/wwdc2024/10207/ I just added contextMenu LazyVGrid(columns: columns, spacing: 40) { ForEach(sortedMatchingAssets) { asset in Button {} label: { asset.landscapeImage .resizable() .aspectRatio(16 / 9, contentMode: .fit) .contextMenu { Button("Test") {} } Text(asset.title) } .buttonStyle(.borderless) } } Attached video with the bug - https://www.icloud.com/iclouddrive/020zq2PxZ_E_1Pr0vE86-8aww#Screen_Recording_2024-06-13_at_9.26.15%E2%80%AFPM
2
2
111
2w
use of @Model macro from SwiftData causes project build to fail
Target tvOS 17.4 macOS Version 14.5 Xcode Version 15.4 (15F31d) I am working on integrating SwiftData (not migrating from CoreData) into an app in active development for tvOS, and I cannot get the project to compile whenever the @Model macro is introduced. I've traced every error back to the code generated by the @Model, and commenting it out removes the errors. I am able to use @Model on a fresh project, but any attempt to import SwiftData results in the build failing with the following errors: /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMe_.swift:1:1 Type 'DeviceModel' does not conform to protocol 'Observable' /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:4:9 Member 'setValue' cannot be used on value of type 'any BackingData<DeviceModel>'; consider using a generic constraint instead /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMe_.swift:4:36 'Observable' is not a member type of struct 'AeolusKit.Observation' /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:4:50 Cannot convert value of type 'String' to expected argument type 'PersistentIdentifier' /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:8:54 Cannot infer key path type from context; consider explicitly specifying a root type /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:12:64 Cannot infer key path type from context; consider explicitly specifying a root type /var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMm_.swift:25:50 Type 'Observation' has no member 'ObservationRegistrar' the code in question causing the error: import Foundation import SwiftData @Model public final class DeviceModel { @Attribute(.unique) public var id: String init(id: String) { self.id = id } } I've already done the following: clean the project erase the contents of the derived directory restart xcode restart my mac. I want to emphasize, I do not believe it is my code causing this issue, as commenting out the @Model result's in a perfectly normal build with no warnings or errors Any help is appreciated
2
0
215
Jun ’24
SwiftUI, tvOS - can't focus buttons
I'm trying to create a simple app for tvOS. But I immediately encountered difficulties. At the top I have a tab selection, and at the bottom there is item management. The problem is that all buttons in HStack are connected into one big button. So I solved it by adding .plain style to the buttons. But now I have a new problem - I can't focus on my buttons for tab selection. Here is the code: struct ContentView: View { var body: some View { VStack { HStack (alignment: .center) { Button("tab1"){} Button("tab2"){} } .frame(width: 500) // works when remove List { HStack { Text("Item 1") Spacer() Button("Button1"){} .buttonStyle(.plain) // added Button("Button2"){} .buttonStyle(.plain) // added } HStack { Text("Item 2") Spacer() Button("Button1"){} .buttonStyle(.plain) // added Button("Button2"){} .buttonStyle(.plain) // added } } } } } I would appreciate any help. Unfortunately, there is very little information on the Internet about designing applications for tvOS, which confuses me.
1
0
265
May ’24
tvOS focus - "ISSUE: This item is not visible onscreen."
Hey, I have an app that presents a UIWindow on top of an existing window. I've made all the needed calls to makeKeyAndVisible() and I can clearly see the new window with the subviews on the screen. I've made the subview receive focus by implementing them as custom views that have canBecomeFocused as true also the window implements preferredFocusEnvironments and returns these subviews The issue the focus engine doesn't want to move to the bottom view, it seems the first one does get focus. The error I'm seeing when printing using UIFocusDebugger.checkFocusability(): <UIFocusUpdateContext: 0x600003318000: previouslyFocusedItem=<FV: 0x102a17f30>, nextFocusedItem=(null), focusHeading=Down> The following issues were found that would prevent this item from being focusable: - ISSUE: This item is not visible onscreen. I can't find any reference online about this error, so it seems something really wild is going on and I can't find the reason. Did anyone encounter this before or knows when this error is being printed? What causes the focus engine to think the view is not visible when it's all there?
1
0
224
May ’24
Focused Tab Item Color in Apple TV Tab Bar Isn't Changing in SwiftUI
I'm developing an Apple TV OS app using SwiftUI. I'm encountering an issue with the color of the tab item. I want the color of the tab item to turn green when focused; for instance, when the tab item is selected, its background color should be green. Below is my current code, but it's not working. I've tried several other approaches, but none have worked. struct ContentView: View { @State private var selectedTab = 0 var body: some View { ZStack(alignment: .topLeading){ TabView(selection: $selectedTab) { HomeView() .tabItem { AppColors.gradientColor1 Label("Home", image: "home-dash") } .tag(0) ProductsView() .tabItem { Label("Products", image: "open box-search") } .tag(1) SearchView() .tabItem { Label("Search", image: "search") } .tag(2) } .accentColor(Color.green) .background(.black) Image("amazontabbarlogo") } } }
0
0
238
May ’24
tvOS play/pause gesture and non-av views
I have a two-view app where the main view is a procedural animation and a secondary view controls settings for the animation. I want to use Play/Pause to toggle between the views, but can't figure out how to do this. Ideally the main view does not have any visible control and the whole screen can be dedicated to the animation view. Attaching onPlayPauseCommand to the main view does not work. I've also tried managing focus using onFocus without success. I'm open to other ways to toggle between the main and settings views, it's just that Play/Pause seems the most intuitive.
1
0
317
Apr ’24
shouldWaitForLoadingOfRequestedResource delegate method not getting called on TVOS app
I'm attempting to integrate DRM into the app. I've developed a prototype, but the delegate method shouldWaitForLoadingOfRequestedResource isn't being triggered on certain devices, although it functions correctly on others. Notably, it's invoked on Apple TV 4K (3rd generation) Wi-Fi (A2737) but not on Apple TV HD (A1625). Are there any specific configurations needed to ensure this method is invoked? let url = URL(string: RESOURCE_URL)! // Create the asset instance and the resource loader because we will be asked // for the license to playback DRM protected asset. let asset = AVURLAsset(url: url) let queue = DispatchQueue(label: CUSTOM_SERIAL_QUEUE_LABEL) asset.resourceLoader.setDelegate(self, queue: queue) // Create the player item and the player to play it back in. let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: playerItem) // Create a new AVPlayerViewController and pass it a reference to the player. let controller = AVPlayerViewController() controller.player = player // Modally present the player and call the player's play() method when complete. present(controller, animated: true) { player.play() } } //Please note if your delegate method is not being called then you need to run on a REAL DEVICE func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool { // Getting data for KSM server. Get the URL from tha manifest, we wil need it later as it // contains the assetId required for the license request. guard let url = loadingRequest.request.url else { print(#function, "Unable to read URL from loadingRequest") loadingRequest.finishLoading(with: NSError(domain: "", code: -1, userInfo: nil)) return false } // Link to your certificate on BuyDRM's side. // Use the commented section if you want to refer the certificate from your bundle i.e. Store Locally /* guard let certificateURL = Bundle.main.url(forResource: "certificate", withExtension: "der"), let certificateData = try? Data(contentsOf: certificateURL) else { print("failed...", #function, "Unable to read the certificate data.") loadingRequest.finishLoading(with: NSError(domain: "com.domain.error", code: -2, userInfo: nil)) return false } */ guard let certificateData = try? Data(contentsOf: URL(string: CERTIFICATE_URL)!) else { print(#function, "Unable to read the certificate data.") loadingRequest.finishLoading(with: NSError(domain: "", code: -2, userInfo: nil)) return false } // The assetId from the main/variant manifest - skd://***, the *** part. Get the SPC based on the // already collected data i.e. certificate and the assetId guard let contentId = url.host, let contentIdData = contentId.data(using: String.Encoding.utf8) else { loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil)) print(#function, "Unable to read the SPC data.") return false } guard let spcData = try? loadingRequest.streamingContentKeyRequestData(forApp: certificateData, contentIdentifier: contentIdData, options: nil) else { loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil)) print(#function, "Unable to read the SPC data.") return false } // Prepare to get the license i.e. CKC. let requestUrl = CKC_URL let stringBody = "spc=\(spcData.base64EncodedString())&assetId=\(contentId)" let postData = NSData(data: stringBody.data(using: String.Encoding.utf8)!) // Make the POST request with customdata set to the authentication XML. var request = URLRequest(url: URL(string: requestUrl)!) request.httpMethod = "POST" request.httpBody = postData as Data request.allHTTPHeaderFields = ["customdata" : ACCESS_TOKEN] let configuration = URLSessionConfiguration.default let session = URLSession(configuration: configuration) let task = session.dataTask(with: request) { data, response, error in if let data = data { // The response from the KeyOS MultiKey License server may be an error inside JSON. do { let parsedData = try JSONSerialization.jsonObject(with: data) as! [String:Any] let errorId = parsedData["errorid"] as! String let errorMsg = parsedData["errormsg"] as! String print(#function, "License request failed with an error: \(errorMsg) [\(errorId)]") } catch let error as NSError { print(#function, "The response may be a license. Moving on.", error) } // The response from the KeyOS MultiKey License server is Base64 encoded. let dataRequest = loadingRequest.dataRequest! // This command sends the CKC to the player. dataRequest.respond(with: Data(base64Encoded: data)!) loadingRequest.finishLoading() } else { print(#function, error?.localizedDescription ?? "Error during CKC request.") } } task.resume() // Tell the AVPlayer instance to wait. We are working on getting what it wants. return true }
0
0
483
Mar ’24
Developing Apple TV app that consumes Local Server
Hello, I am new to Apple TV Development. I am researching if it would be possible to develop a tvOS App for IPTV that consumes content entirely from an API in the local network (I have domain such as sampleserver.com that points to a local network IP such as 192.168.1.10 ) and also plays back m3u8 HLS sources (live and VOD) produced in that local network server. No content comes from the cloud. Here are my questions: Would Apple approve this kind of app in the App Store? Or will Apple ask me to instead deploy this as a "Custom App" with Apple Business Manager and an MDM server? Is there an App Builder technology that fits better for this use case, such as TVML? If this app is published in the App Store and a user that is not in that local network, is there a guideline from Apple that I should follow to let the user know that he does not have access to the local content?
0
0
364
Mar ’24
Excluding Apple TV 5,3 (Apple TV HD 2015) from supported device list for for our game?
We have built the game on Unreal engine 4 and we have optimised the game to run on tvOS devices newer than 2017 (viz. Apple TV 4k and above). We could not bring it down to support Apple TV HD (2015) due to its visual and memory requirements. Is there a way to exclude Apple TV HD from support list. We couldnt find any required device capability to add to info.plist (eg: iphone-ipad-minimum-performance-a12, we tried it but this does not work for tvOS build).
0
1
406
Mar ’24
[tvOS] ScrollView with Text does not scroll
I'm trying to do something so seemingly basic, yet I can't get it to work and I'm flummoxed. In a basic, vanilla SwiftUI app for tvOS, embed a single Text element with a very long string (hundreds of lines) in it: struct ContentView: View { var body: some View { ScrollView(.vertical) { Text(veryLargeString) .focusable() } } } Then fire up the app on tvOS, and it will not scroll. No matter what I do. Pressing arrow keys, swiping fast with my thumb, and nothing. It will not move. Ironically, in the Xcode SwiftUI Preview window—it does scroll, so that's always a fun tease. What I do know is that the focus engine is throwing a few errors, so it's leading me to believe the issue is with how I have the focusable element attached. I'm using a combination of -UIFocusLoggingEnabled YES as well as listening for UIFocusSystem.movementDidFailNotification. Unfortunately since this is SwiftUI, the notification failure and debugging logs aren't really all that actionable. Help appreciated!
1
1
625
Mar ’24