Post not yet marked as solved
I have picture-in-picture working on iOS, finally, because v15 introduced an initializer for AVPictureInPictureController() that can be used with an AVSampleBufferDisplayLayer.
However, using a largely shared code base (at least for the video display portion of the app), isPictureInPicturePossible is false when I try to PiP on tvOS.
My AVAudioSession is configured with .playback.
The app itself has Audio, AirPlay and Picture in Picture mode enabled in the Background Modes section.
Has anyone got PiP working on tvOS? Are there any tvOS-related requirements that differ from iOS?
Post not yet marked as solved
I updated my Apple TV 4k without usb-c port using tvOS 13 beta 2 ota. Now my Apple TV 4K shows a warning triangle the provides a link to support.apple.com/appletv/restore. I was not able to restore the Apple TV. So I brought it to an Apple Store they were not able to help me.
In our tvOS app we have to inject some tiny bit of data in the master manifest and leave the rest as is. The idea I was trying to implement here is intercepting the master manifest request with use of AVAssetResourceLoaderDelegate, and just redirect all consequent request, so AVKit can handle it on its own. In order to actually mimic the original requests, I made a copy of what is in AVAssetResourceLoadingRequest and adjusted only the parts required:
override func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
guard let url = loadingRequest.request.url, url.scheme == Self.assetScheme else {
return super.resourceLoader(resourceLoader, shouldWaitForLoadingOfRequestedResource: loadingRequest)
}
guard var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
LOG.error("Could not obtain url components from resource request: \(loadingRequest.request)")
return super.resourceLoader(resourceLoader, shouldWaitForLoadingOfRequestedResource: loadingRequest)
}
urlComponents.scheme = "https"
guard let assetURL = try? urlComponents.asURL() else {
LOG.error("Could not make url from URL components \(urlComponents)")
return super.resourceLoader(resourceLoader, shouldWaitForLoadingOfRequestedResource: loadingRequest)
}
let assetURLRequest = (loadingRequest.request as NSURLRequest).mutableCopy() as? NSMutableURLRequest
assetURLRequest?.url = assetURL
guard let taskRequest = assetURLRequest?.copy() as? URLRequest else {
LOG.error("Could not convert url request \(String(describing: assetURLRequest))")
return super.resourceLoader(resourceLoader, shouldWaitForLoadingOfRequestedResource: loadingRequest)
}
if url == masterManifestURL {
// ...custom logic comes here...
} else {
loadingRequest.response = HTTPURLResponse(url: assetURL, statusCode: 302, httpVersion: "HTTP/1.1", headerFields: nil)
loadingRequest.redirect = taskRequest
loadingRequest.finishLoading()
}
return true
}
That works just fine, but only for VOD assets. For linear/live assets however only first bunch of data is loaded, when it ends, player does not request the next part of the sliding window and it hangs loading. I believe that the problem is somewhere with the custom logic, so I decided to list it separately:
urlSession.dataTask(with: taskRequest) { [weak self] data, response, error in
loadingRequest.response = response
if let data = data, let dataRequest = loadingRequest.dataRequest, let self = self, let manifestString =
String(data: data, encoding: .utf8) {
let adjustedManifestString = self.adjustAudioMetadataForManifest(manifestString)
if let adjustedData = adjustedManifestString.data(using: .utf8) {
dataRequest.respond(with: adjustedData)
} else {
LOG.error("Could not complement audio labels in master manifest")
dataRequest.respond(with: data)
}
}
if let error = error {
loadingRequest.finishLoading(with: error)
} else {
loadingRequest.finishLoading()
}
}.resume()
I noticed that unlike apple player, the custom resource loader requests have different encoding headers. It also was not clear whether data length and offset is more crucial for linear than it is for VOD, so I added this header as well:
if let dataReq = loadingRequest.dataRequest, !dataReq.requestsAllDataToEndOfResource {
let offsetEnd = dataRequest.requestedOffset + dataRequest.requestedLength - 1
assetURLRequest?.addValue("bytes=\(dataReq.requestedOffset)-\(offsetEnd)", forHTTPHeaderField: "Range")
}
if loadingRequest.contentInformationRequest != nil {
assetURLRequest?.setValue("identity", forHTTPHeaderField: "Accept-Encoding")
}
I also fulfilled contentInformationRequest which I forgot originally (but it still worked for VOD):
if let contentInformationRequest = loadingRequest.contentInformationRequest {
contentInformationRequest.contentLength = Int64.max
if let mimeType = response?.mimeType {
let utiType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType as CFString,
nil)
contentInformationRequest.contentType = utiType?.takeRetainedValue() as? String
}
contentInformationRequest.isByteRangeAccessSupported = true
}
and finally adjusted the data response with requested length:
if dataRequest.requestsAllDataToEndOfResource {
dataRequest.respond(with: dataToRespond)
} else {
let offsetStart = Int(dataRequest.requestedOffset)
let offsetEnd = Int(dataRequest.requestedOffset + dataRequest.requestedLength)
dataRequest.respond(with: dataToRespond[offsetStart ..< offsetEnd])
}
All those adjustments happen only for master manifest request, and I just redirect all other request to proper url with https schema. Unfortunately all adjustments don't seem to make any difference. All work equally good with VOD assets but doesn't allow linear assets to play beyond the the very first video record (so sliding window just hangs)
Is there some documentation on how to properly do the custom resource loader for a linear/live asset I can refer to in order to make it work?
Post not yet marked as solved
When I try to build a demo app for exploring PIP Swap feature using custom player view controller, I'm facing an issue that play and pause not working on the PIP window playback.
But when I use AVPlayerViewController. I can pause and play the PIP window playback.
Here is the sample code attached.
var nowPlayingSession: MPNowPlayingSession?
var player: AVPlayer? {
didSet {
playerLayer = AVPlayerLayer(player: player)
if player != nil {
nowPlayingSession = MPNowPlayingSession(players: [player!])
nowPlayingSession?.remoteCommandCenter.pauseCommand.addTarget(handler: { [weak self] event in
guard let self = self else { return .commandFailed }
self.pause()
return .success
})
nowPlayingSession?.remoteCommandCenter.playCommand.addTarget(handler: { [weak self] event in
guard let self = self else { return .commandFailed }
self.play()
return .success
})
nowPlayingSession?.remoteCommandCenter.togglePlayPauseCommand.addTarget(handler: { [weak self] event in
guard let self = self else { return .commandFailed }
self.togglePlayPause()
return .success
})
}
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
playerLayer?.frame = view.bounds
publishNowPlayingMetadata()
}
func publishNowPlayingMetadata() {
var nowPlayingInfo = [String: Any]()
nowPlayingInfo[MPMediaItemPropertyTitle] = "Unknown Content"
nowPlayingInfo[MPMediaItemPropertyPlaybackDuration] = 15.0
nowPlayingInfo[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
nowPlayingInfo[MPMediaItemPropertyArtist] = "Unknown Artist"
nowPlayingInfo[MPMediaItemPropertyAlbumArtist] = "Unknown Album Artist"
nowPlayingInfo[MPMediaItemPropertyAlbumTitle] = "Unknown Album Title"
nowPlayingSession?.nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo
nowPlayingSession?.becomeActiveIfPossible()
}
Ref:
https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_playback_in_tvos (The above changes are made on top of it. )
Please suggest for changes.
We have both an iOS app and a tvOS app.
We'd love to achieve the following scenario:
iOS app should be able to detect Apple TV devices in the local network.
When the user selects the apple TV device, check if the our tvOS app on apple TV is installed or not on the selected apple tv, If the app is not installed then iOS app can open the app store to launch the install page for the tvOS app on apple tv.
The user can download/installation the app of the tvOS app.
If the tvOS app is installed then launch the tvOS App on the apple TV.
Are there any APIs available to achieve this scenario?
Post marked as Apple Recommended
When archiving and uploading a build of our tvOS app to App Store Connect with Xcode 13.3RC, it gets rejected with
TMS-90562: Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
When archiving and uploading with Xcode 13.2.1 the build is accepted and processed.
I could not find any rpath issues when inspecting the binary with otool -L and otool -l.
Has anyone else experienced the this issue with Xcode 13.3RC?
I've filed feedback FB9952607
Post not yet marked as solved
How do I stop the menu button from going back to the previous view in a SwiftUI tvOS app?
Post not yet marked as solved
Hi,Could anyone tell me why the memory usage gets increased by almost 7MB when running that script:for (var i=0; i < 10000; ++i) {
new XMLHttpRequest();
}(of course this is just a test to pinpoint my issue, not a code that would be usefull in any manner!)There isn't any reference to those objects, I thought they wouldn't be kept in memory...Note: to get the numbers I look at the "Memory Report" on XcodeThanks
Post not yet marked as solved
Hi,
I am facing a weird issue where my app crashes when loading a storyboard. It was working fine, and seems to crash all of a sudden without any changes done to the code.
I have tried to clean the build, delete the app and try again to no avail. I also tried deleting the storyboard in question by removing just the reference and adding it again, still no change.
I am stuck with the error Could not load NIB in bundle and am not sure how to proceed at this point. Any pointers to resolve this?
Stack trace:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </private/var/containers/Bundle/Application/9105DD59-18EE-4173-A3EB-C3896D922D0F/MyApp.app> (loaded)' with name '3ug-Hv-1MS-view-Qxp-U7-Q2L''
*** First throw call stack:
(0x193eeeb4c 0x1938105ac 0x193eeea30 0x1d2ff2244 0x1d2d3f6c4 0x1d2d3fa50 0x1d2d40180 0x1026c205c 0x1026c1f6c 0x1d2d40f10 0x1d2d41578 0x1d2d5fb98 0x1d2d3aee8 0x1026c4e28 0x1026c4eb8 0x1d2ff0844 0x1a0f02324 0x1a0f02050 0x1d2ff4b48 0x1a0f02324 0x1a0f02550 0x1a0f02050 0x1d2fef9d4 0x1d2ff2498 0x1d34dd498 0x1024ac080 0x1026675a8 0x10266673c 0x102665f1c 0x1026667a0 0x1042adf08 0x105630cfc 0x1056310f4 0x105631aa0 0x10563222c 0x10569ed34 0x105631ac8 0x10563222c 0x105660dd0 0x10566139c 0x105644c14 0x105614df0 0x10439b908 0x10439d1cc 0x1043aba88 0x1043ab6dc 0x193e62458 0x193e5c8f8 0x193e5b9c4 0x19702ab40 0x1d336b10c 0x1d3370570 0x10287f360 0x10381d1d0)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </private/var/containers/Bundle/Application/9105DD59-18EE-4173-A3EB-C3896D922D0F/MyApp.app> (loaded)' with name '3ug-Hv-1MS-view-Qxp-U7-Q2L''
terminating with uncaught exception of type NSException
Xcode : 13.1
tvOS: 15.4.1
Post not yet marked as solved
Hello.
I have an interactive component based on UISegmentedControl that is displayed in the top header of a UICollectionView laid out using UICollectionViewCompositionalLayout.
The UICollectionView is displayed within a container UIViewController. That container has call to action buttons. When the focus is on one of these buttons and the user swipes down on the remote, I would like the focus to be redirected to the top header.
Where should I place the UIFocusGuide ?
I have tried adding it to the container UIViewController at the same level as the buttons and UICollectionView (in between) to no avail.
Post not yet marked as solved
Hi,
I'm trying to develop a simple app, that presents some dashboard on the screen, and in the background I'm using some music app (Apple Music or Spotify) - while I see my dashboard. While listening to music, I’ve noticed that after a few minutes, (1-2), the music app takes priority, displaying the album art, title and artist.
how do I prevent it?
thanks a lot in advance!
Post not yet marked as solved
I reset the old player item(remove all observers also) and avplayercontroller then add a new avplayerviewcontroller instance and avplayer and player item on playing a new asset/stream etc. It works fine and no crash in tvos 14, 13 etc. But in tvos 15.2 and above i get the following stack trace.
Below are the details i could collect from firebase, please check if it could help you to infer the cause of the crash. Thanks!
Crashed: com.apple.main-thread
SIGSEGV 0x00000007f2e51110
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x7624 class_getMethodImplementation + 32
1 Foundation 0xa1f30 _NSKVONotifyingOriginalClassForIsa + 28
2 Foundation 0x9db38 _NSKeyValueObservationInfoGetObservances + 272
3 Foundation 0xa8c50 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 244
4 Foundation 0xa9540 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 68
5 Foundation 0xa2080 _NSSetObjectValueAndNotify + 284
6 AVKit 0xe6b8 -[AVInterstitialController dealloc] + 32
7 AVKit 0x356e4 -[AVPlayerControllerTVExtras .cxx_destruct] + 144
8 libobjc.A.dylib 0x7d68 object_cxxDestructFromClass(objc_object*, objc_class*) + 112
9 libobjc.A.dylib 0x1dad0 objc_destructInstance + 88
10 libobjc.A.dylib 0x24f90 _objc_rootDealloc + 52
11 libsystem_blocks.dylib 0x37f8 _Block_release + 184
12 libdispatch.dylib 0x4f84 _dispatch_client_callout + 16
13 libdispatch.dylib 0x12164 _dispatch_main_queue_callback_4CF + 916
14 CoreFoundation 0x7a698 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
15 CoreFoundation 0x74b18 __CFRunLoopRun + 2528
16 CoreFoundation 0x73bf4 CFRunLoopRunSpecific + 572
17 GraphicsServices 0x6afc GSEventRunModal + 160
18 UIKitCore 0xa9ccd0 -[UIApplication _run] + 1080
19 UIKitCore 0xaa20cc UIApplicationMain + 164
20 XXXXXXX 0xc474 (Missing UUID xxxxxxxxx…)
21 ??? 0x1030e91d0 (Missing)
Post not yet marked as solved
Hi!
I searched around but could not find any recent references on AppleTV planning to support HTML/Webview.
Does anyone have any updates about this, if Apple is planning to add support to HTML/WKWebView in the near future?
Thanks!
Post not yet marked as solved
Hi all,
I have downloaded my entire apple movie library to my Mac so I can stream it to my various devices locally. What I’d like to do is show the cover art in plex and when I click it it launches to the movie in the computers app on my Apple TV.
Getting the cover art in plex is easy enough, but is there any way to launch an Apple TV app to go directly to a specific content location?
Example: can I do something like
http:/{Apple TV IP}/computers?movie=UP
Post not yet marked as solved
Hi there,
I'm experiencing several crashes on JavaScriptCore pas_panic_on_out_of_memory_error, only on devices with tvOS 15.4 and 15.4.1. This happens with users using the app for several hours as well as 5 seconds after launching the app.
Devices: AppleTV6,2 and AppleTV5,3
Thread 14 —
JavaScriptCore pas_panic_on_out_of_memory_error (JavaScriptCore)
JavaScriptCore bmalloc_try_iso_allocate_impl_impl_slow (JavaScriptCore)
JavaScriptCore bmalloc_heap_config_specialized_local_allocator_try_allocate_small_segregated_slow (JavaScriptCore)
JavaScriptCore bmalloc_allocate_impl_casual_case (JavaScriptCore)
JavaScriptCore ***::String::String(char16_t const*, unsigned int) (JavaScriptCore)
JavaScriptCore JSC::LiteralParser<char16_t>::parsePrimitiveValue(JSC::VM&) (JavaScriptCore)
JavaScriptCore JSC::LiteralParser<char16_t>::parse(JSC::ParserState) (JavaScriptCore)
JavaScriptCore JSC::jsonProtoFuncParse(JSC::JSGlobalObject*, JSC::CallFrame*) (JavaScriptCore)
JavaScriptCore llint_entry (JavaScriptCore)
JavaScriptCore llint_entry (JavaScriptCore)
JavaScriptCore llint_entry (JavaScriptCore)
JavaScriptCore llint_entry (JavaScriptCore)
JavaScriptCore vmEntryToJavaScript (JavaScriptCore)
JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) (JavaScriptCore)
JavaScriptCore JSC::boundThisNoArgsFunctionCall(JSC::JSGlobalObject*, JSC::CallFrame*) (JavaScriptCore)
JavaScriptCore vmEntryToNative (JavaScriptCore)
JavaScriptCore JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) (JavaScriptCore)
JavaScriptCore JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) (JavaScriptCore)
JavaScriptCore JSObjectCallAsFunction (JavaScriptCore)
JavaScriptCore -[JSValue invokeMethod:withArguments:] (JavaScriptCore)
ITMLKit -[IKJSObject invokeMethod:withArguments:] (ITMLKit)
ITMLKit -[IKJSEventListenerObject invokeMethod:withArguments:thenDispatchEvent:extraInfo:] (ITMLKit)
ITMLKit __43-[IKJSXMLHTTPRequest setRequestReadyState:]_block_invoke (ITMLKit)
ITMLKit -[IKAppContext _doEvaluate:] (ITMLKit)
ITMLKit -[IKAppContext _evaluate:] (ITMLKit)
ITMLKit __41-[IKAppContext evaluate:completionBlock:]_block_invoke (ITMLKit)
ITMLKit -[IKAppContext _sourcePerform] (ITMLKit)
ITMLKit -[IKConcurrentEvaluator lockSchedulingForEvaluation:] (ITMLKit)
ITMLKit IKRunLoopSourcePerformCallBack (ITMLKit)
CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (CoreFoundation)
CoreFoundation __CFRunLoopDoSource0 (CoreFoundation)
CoreFoundation __CFRunLoopDoSources0 (CoreFoundation)
CoreFoundation __CFRunLoopRun (CoreFoundation)
CoreFoundation CFRunLoopRunSpecific (CoreFoundation)
ITMLKit -[IKAppContext _jsThreadMain] (ITMLKit)
Foundation __NSThread__start__ (Foundation)
libsyste...ad.dylib _pthread_start (libsystem_pthread.dylib)
libsyste...ad.dylib thread_start (libsystem_pthread.dylib)
This issue seems very similar to this existing thread, although not sure its related
I put a supervised Apple TV in sigle app mode. Things were working fine until I unplugged the device from power.After replugging power, the designated app restarted correctly, but the Apple TV lost its pairing with the Mac I previously used for the configuration and there is not way to make it visible again. Choosing paired devices from the Apple Configurator 2 won't show anything.Even unplugging or trying a reset via remote (menu+home for 6 seconds) won't improve the situation: the Apple TV just restarts with the designated app and won't show up among paired devices.Even Xcode won't show the Apple TV among connected devices.Is there any way to exit from this ? Is there a way to force disable single app mode ? (so to at least gain access to Apple TV's settings menu)
Post not yet marked as solved
I'd like to develop a music visualizer app for tvOS which has the ability to listen to whatever background audio is playing (like Spotify, Pandora, etc.). Does anyone know if this is even possible on iOS/tvOS? In other words, there would have to be some functionality that allows the system audio output to be treated like an audio input.
I imagine that it would be the same functionality as doing a screen recording capture, at least the audio part.
My goal is to be able to do this programatically (Objective-C) so that the user doesn't have to do anything, it just "works" out of the box, so to speak.
Thanks
I'm able to build and run the TV app with the TVTopShelf extension on simulators and physical Apple TVs but I get an error when I try to validate (or distribute) the archive built from XCode. The error says:
App Store Connect Operation Error - Asset validation failed
The log files don't provide more information:
"Error Domain=ContentDelivery Code=90362 "App Store Connect Operation Error" UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=App Store Connect Operation Error, NSLocalizedRecoverySuggestion=Asset validation failed}"
As far as I know the certificate, the identifiers and the provisioning profiles for both the tvOS app and the TVTopShelf extension are OK. When I choose to manually select signing options, I can set the provisioning profiles for both the app and the extension and XCode does not complain about them.
Is there something specific to know when distributing an app with an extension app? Is there some configuration to set on AppStoreConnect side? Or common pitfalls to avoid?
Thanks for your help.
Post not yet marked as solved
Hi,
Can we create a dependent/independent WatchOS application and a tvOS application using Objective C ? If yes, can some sample be shared please.
When I go to create these applications from XCode, in the language dropdown, only Swift is available as an option.
Thanks !
Is is possible now to create your own channel for Apple TV that can serve video content?