tvos

AVPlayerViewController inside a view is not showing the playback controls

廉价感情. 提交于 2019-12-04 17:27:17
I am working with apple tv. I have a UIView inside my UIViewController. I am adding AVPlayerViewController as subview of my UIView. UIView's frame is CGRect(x: 50, y: 50, width: 1344, height: 756). I am setting AVPlayerViewController frame equals to my UIView's frame. Issue is that video plays fine in its frame but the controls like pause, play, forward etc. are hidden and not working. But when I set frame as CGRect(x: 0, y: 0, width: 1920, height: 1080), controls are visible and working. My code is as per below: let url = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") let

How to cancel DispatchQueue.main.asyncAfter(deadline: time) in Swift3? [duplicate]

只谈情不闲聊 提交于 2019-12-04 16:02:06
问题 This question already has answers here : Cancel a timed event in Swift? (7 answers) Closed 2 years ago . Description: I'm currently using the following code to see if the user has stopped typing in the searchBar. I would like to cancel it everytime the user immediately starts typing after 0.5 seconds. Code: DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { // your function here } Question: How do I cancel DispatchQueue.main.asyncAfter if the user starts typing again in Swift3 ? What I

Forced Touch with tvOS

房东的猫 提交于 2019-12-04 15:13:37
Does anybody know how to detect a forced touch/click on the remote control with tvOS? I want to use the click in a Sprite Kit scene to open a 'game paused alert'. I have no UIKit controls which have the focus and will react on the click. I'm already using the 'normal' touch events on the remote control to move my sprites around. Apple suggests using UIPressesEvent 's to detect presses/clicks. override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) { for item in presses { if item.type == .Select { self.view.backgroundColor = UIColor.greenColor() } } } override func

Apple Push Notifications in tvOS

与世无争的帅哥 提交于 2019-12-04 14:56:41
Hi i am a newbie to tvOS. I have an TV application which is registered for APNS. But while i push a notification i am not able to get the notifications. i am getting the device token but not the notification. While i try with the Mobile Devices i am getting the notifications,But not in the tvOS why is it so...? How can i solve this..? let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in if granted == true { print("Allow") UIApplication.shared.registerForRemoteNotifications() } else { print("Don't Allow") } } func

How to make a UIView focusable using the focus engine on Apple TV

不羁的心 提交于 2019-12-04 12:22:30
问题 Is it possible to make a UIView focusable? Or should I just use a custom UIButton for all possible views? I tried to override canBecomeFocused but nothing happened. 回答1: So the problem was that I didn't notice that my cell got focus. To wrap this up, you need to implement 1) override canBecomeFocused 2) override "didUpdateFocusInContext:withAnimationCoordinator:" method to be able to highlight the cell as focused Swift 2.3: override func canBecomeFocused() -> Bool { return true } override

Unexpected motion effect oscillations in tvOS

半腔热情 提交于 2019-12-04 10:11:49
I am experiencing motion effect oscillations using the following code import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) self.window!.rootViewController = ExampleController() self.window!.makeKeyAndVisible() return true } } class ExampleController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let redView = UIView(frame: CGRect(x:

Make UILabel focusable and tappable (tvOS)

荒凉一梦 提交于 2019-12-04 01:22:03
问题 I'm trying to implement 6 lines high description label and I want it to be focusable. Ideally that would mean extending UILabel class to make a custom component. I tried that by implementing canBecomeFocused and didUpdateFocusInContext but my UILabel doesn't seem to get any focus. I also tried replacing UILabel with UIButton, but buttons aren't really optimised for this sort of thing. Also that would mean I'd need to change buttonType on focus from custom to plain.. and buttonType seems to be

Generate the Dominant Colors for an RGB image with XMLHttpRequest

好久不见. 提交于 2019-12-03 14:40:12
A Note For Readers: This is a long question, but it needs a background to understand the question asked. The color quantization technique is commonly used to get the dominant colors of an image. One of the well-known libraries that do color quantization is Leptonica through the Modified Median Cut Quantization (MMCQ) and octree quantization (OQ) Github's Color-thief by @lokesh is a very simple implementation in JavaScript of the MMCQ algorithm: var colorThief = new ColorThief(); colorThief.getColor(sourceImage); Technically, the image on a <img/> HTML element is backed on a <canvas/> element:

YouTube URL Scheme tvOS

假如想象 提交于 2019-12-03 14:03:31
I am trying to open YouTube's app from my application with the URL scheme or the YouTube.com domain which opens YouTube's app directly on an iOS device. This is the code I tried: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"youtube://results?search_query=trailer+%@",movieTitle]]]; and [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://www.youtube.com/results?search_query=trailer+%@",movieTitle]]]; But nothing seems to work. Any ideas on how to retrieve the URL scheme for YouTube's tvOS application

Rendering PDF in Apple TV tvOS

ぃ、小莉子 提交于 2019-12-03 13:58:14
I am working on an addition to my tvOS app that would allow viewing of PDFs stored in the app. However, without UIWebView, I'm at a loss on how to do this. I've asked question in other places, and get greeted with a link to a wordy and helpless document from Apple about the APIs that can be used, and even here it has been referenced (CGPDFPage) but no real guide on how to implement this. Has anyone successfully done this on tvOS, and if so, would you help me get started in this process? Below is some code that I wrote and tested in tvOS. Note that this is in Objective-c. I've created two