Post not yet marked as solved
In our tvOS app we have a couple of hooks into the native side where we receive events over a WebSocket in (using CocoaAsyncSocket) native and propagate those events into the JavaScript layer. The calls into the JS layer are structured like this:self.receiveQueue.addOperation {
websocket.invokeMethod("onmessage", withArguments: [["data": text]])
}Where `receiveQueue` is an `OperationQueue`. This works great most of the time, but we occasionally see application crashes where it seems a memory reference has gone bad. However, we've found that if we take the JavaScript function being called and wrap it in asetTimeout(() => {
// Do the work here
}, 0)this resolves nearly all the issues. We still get an application crash here and there but the `setTimeout` does the trick most of the time.This leads me to the following question. What's the proper way to call back to a TVJS application from native? Should I be using DispatchQueue.main.async { } instead of an OperationQueue? How does this relate to doing work on the main UI thread?Thanks!
Post not yet marked as solved
I have an app with a Top Shelf Extension that uses a UserDefaults(suiteName: "app-group-name") to share data between the main app and the extension. I recently enabled the "Run as Current User" capability for both the app itself and the extension. My expectation was that the Top Shelf content would change when the user changes in tvOS but this is not the case.
What changes are required such that the Top Shelf content can be changed by tvOS user?
Post not yet marked as solved
Can anyone provide an example on how the DataSource API can be used? https://developer.apple.com/documentation/tvmljs/datasource?changes=latest_minorIt was added in tvOS 13 but the example in the docs (Binding JSON Data to TVML Documents) wasn't updated to use it.
Post not yet marked as solved
The TVML documentation mentions a contentMode property for images yet it doesn't specify what the actual values for this are (I submitted a bug report for this). Does anyone know how to properly use this property in a scenario like below:<lockup><img src="..." width="200" height="300" contentMode="????" /></lockup>I've tried "aspect-fit", "aspectFit", "scaledAspectFit", etc and it does not change the image at all. Ultimately I'm trying to get the image to fit into the container and maintain its aspect ratio.Thanks!
Post not yet marked as solved
We have a TVMLKit based application that makes use of the background audio capabilities of the productTemplate via the <audio /> element. Is there anyway to programmatically pause/play/stop that playback whether it be in JS or native?Thanks!
Post not yet marked as solved
I have a need that I'd like to solve with a UITabBarController but I'm struggling to understand if it's actually possible. The primary reason I want to use the UITabBarController is because I get all the interactions and animations for 'free' with the Siri Remote and I'm hoping to avoid implementing a custom UITabBar precisely for that reason.The mockup of the view I'm after is here: https://imgur.com/a/oOSRLpvIn this mockup the items in the tab bar are view controllers that only take up a portion of the screen partially obscuring the underlying 'custom view.' In my actual application this view controller is part of a UINavigationController.With that said I've attempted to create a custom UIViewController with a container view that contains a UITabBarController. On the surface this appears to work but has one glaring problem that I haven't figured out how to resolve. That problem is that when the tab bar is in focus and I press the Menu button on the Siri Remote it doesn't hide the tab bar like I'd expect it to, it pops the entire view controller off the navigation stack.My next stop would be to remove the concept of a container view and make the view controller itself a UITabBarController. Since UITabBarControllers take up the whole window I don't know how to provide a custom 'background view' and have tab bar items only provide part of the view.I know this is possible because this interface I'm after is essentially identical to the behavior that the tvOS player interface has. What I don't know is if it's possible with a UITabBarController or if I have to go with a plain UITabBar and roll my own animations and gesture recognizers.
Post not yet marked as solved
I'd like to present a native view from TVML/JS that has similar capabilities from a UI perspective to the player interface. The requirements are to:1. Be able to swipe up or press menu to dismiss the tab bar without popping the controller off the navigation stack2. If the tab bar is not visible pop the controller off the navigation stack when the menu button is pressed.My first attempt was to use the navigation controller attached to the app controller to present a UITabBarController. Unfortunately pressing the menu button pops the tab bar controller off the stack instead of dimissing the menu bar.Am I approaching this wrong? Should I be using a custom view controller with a UITabBar instead of a UITabBarController. Please assume that I cannot use the TVML menu bar template as I do need to present some native created controls.Thanks!
Say I have a TVML app where I have implemented a custom placeholder like so:<img style="tv-placeholder: my-placeholder" />and my custom interface creator:class MyExtendedInterfaceCreator: NSObject, TVInterfaceCreating {
override init() {
super.init()
}
func resourceImage(name resourceName: String) -> UIImage? {
if resourceName == "my-placeholder" {
return UIImage(named: "placeholders/my-placeholder")
}
return nil
}
}How do I change this code such that I can return a different placeholder if the UIUserInterfaceStyle is 'light' or 'dark'?
We've had a TVML-based Apple TV app since tvOS 9. Our users are reporting that on their Apple TV 4Ks fonts look blurry.This image below really shows the difference: https://imgur.com/a/lm9YgBeThese are two screenshots taken directly from the Apple TV 4K, but zoomed in to show the difference. The DI on the left looks significantly worse than the DI on the right. The one from the left is our application, and the one on the right is from a brand new TVML-app project generated by XCode.What can we do to get our application to use crisper fonts?Thanks!
I have a scenario where I want to have an <img /> inside a <lockup /> but I want the image to maintain its aspect ratio. The dimensions of the image may not be known ahead of time such that a proper `width` and `height` attribute may be set on the <img /> tag. This increasingly problematic with attempting to use <prototype /> as the image dimensions need to be known up front. I'd prefer to be able to fix one dimension to a known value, say `height="280"` and have the <img /> element automatically set its width based on the actual width of the image to maintain the proper aspect ratio.Looking through the docs (https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/ATV_Template_Guide/TVJSAttributes.html) it looks like this may be available with the `contentMode` attribute but it doesn't appear to work.The following combinations were tried without success:<lockup style="height: 300; width: 200">
<img src="path/to/image" contentMode="aspect-fit" />
</lockup>
<lockup style="height: 300; width: 200">
<img src="path/to/image" contentMode="aspect-fit" height="300"/>
</lockup><img />s won't display if both the `height` and `width` attribute are not set which seems to go against the idea of the `contentMode` attribute. When it is set the aspect ratio is fixed at that time and it doesn't appear that `contentMode` applies. This was tried against the latest version of tvOS 11.3.
Post not yet marked as solved
With the Apple TV 4th gen I was able to debug on device by plugging a USB-C cable into my Mac like I would with an iPhone. However, the new Apple TV 4K does not have this option. In the devices and simulators window it doesn't appear that there's anyway to pair with it wirelessly. Is it possible to run and debug apps via XCode on the 4K Apple TV?
Post not yet marked as solved
Is there an example of using <section> within a <menuBar>? What's it's purpose? I'd like to put a read only value (preferably either left/right aligned) in the <menuBar> and I'm not sure if this is the mechanism to do that.Thanks!