Hi, I am creating audio player in tvos which is quite similar to Podcast App (Playing in background and stoping when user press pause button from Tv Remote). It is working fine when app is in foreground but creating issue when app is background. Audio Player is not getting stopped when user is pressing play/Pause button from remote.
I have added MPRemoteCommandCenter target to my home controller. And I am using my audio player as single ton class. Below is snap shot of my code
private func setUpCommand() {
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.playCommand.isEnabled = true
commandCenter.pauseCommand.isEnabled = true
commandCenter.playCommand.addTarget {(commandEvent) -> MPRemoteCommandHandlerStatus in
PodcastPlayer.shared.playPauseCommad()
return .success
}
commandCenter.pauseCommand.addTarget {(commandEvent) -> MPRemoteCommandHandlerStatus in
PodcastPlayer.shared.playPauseCommad()
return .success
}
}
Above code is not triggering when app is in background.
Post
Replies
Boosts
Views
Activity
I am using textview in cell and making scrollable false. It is working fine up to iOS15, but getting crash in iOS16.
If I am making textview scrollable to true, then it is not crashing but as soon as I am making textview scrollable false and start scrolling table view it is getting crashed.
I need textview should not be scrollable .
Crash Logs:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x00007ff80041f225 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007ff800049c6f objc_exception_throw + 48
2 CoreFoundation 0x00007ff8004a51a5 _CFThrowFormattedException + 200
3 CoreFoundation 0x00007ff8004a2cc1 -[__NSArrayM insertObject:atIndex:].cold.2 + 0
4 CoreFoundation 0x00007ff80030b2c4 -[__NSArrayM insertObject:atIndex:] + 993
5 UIFoundation 0x00007ff8044c9086 __55-[__NSTextSelectionLineFragmentInfo _fetchCaretOffsets]_block_invoke + 980
6 UIFoundation 0x00007ff804512117 __95-[NSTextLineFragment enumerateCaretOffsetsWithTextSelectionDataSource:baseLocation:usingBlock:]_block_invoke + 106
7 CoreText 0x00007ff801966f07 _ZNKSt3__18functionIFvdlbPbEEclEdlbS1_ + 51
8 CoreText 0x00007ff8019667b6 _ZNK5TLine21EnumerateCaretOffsetsENSt3__18functionIFvdlbPbEEE + 8290
9 CoreText 0x00007ff801960f83 CTLineEnumerateCaretOffsets + 80
10 UIFoundation 0x00007ff804511f29 -[NSTextLineFragment enumerateCaretOffsetsWithTextSelectionDataSource:baseLocation:usingBlock:] + 287
11 UIFoundation 0x00007ff8044dd54a -[NSTextLayoutManager enumerateCaretOffsetsInLineFragmentAtLocation:usingBlock:] + 152
12 UIFoundation 0x00007ff8044c8b6e -[__NSTextSelectionLineFragmentInfo _fetchCaretOffsets] + 379
13 UIFoundation 0x00007ff8044c95d0 -[__NSTextSelectionLineFragmentInfo _cache] + 35
14 UIFoundation 0x00007ff8044ca2ac -[__NSTextSelectionLineFragmentInfo indexForPrimaryLocation:] + 33
15 UIFoundation 0x00007ff8044c9cee -[__NSTextSelectionLineFragmentInfo offsetForLocation:] + 22
16 UIFoundation 0x00007ff8044d93fd __76-[NSTextLayoutManager enumerateTextSegmentsInRange:type:options:usingBlock:]_block_invoke_2 + 785
17 UIFoundation 0x00007ff8045123e4 -[NSTextLineFragment enumerateTextSegmentBoundsInTextRange:withTextElementProvider:baseLocation:usingBlock:] + 535
18 UIFoundation 0x00007ff8044d8f94 __76-[NSTextLayoutManager enumerateTextSegmentsInRange:type:options:usingBlock:]_block_invoke + 1404
19 UIFoundation 0x00007ff8044d8692 -[NSTextLayoutManager enumerateTextSegmentsInRange:type:options:usingBlock:] + 1140
20 UIKitCore 0x00000001190b7d80 -[NSTextLayoutManager(UIKitAdditions) ui_contentSizeForLastContainerView] + 507
21 UIKitCore 0x00000001189b97a9 -[_UITextKit2LayoutController usedRectForTextContainer:] + 194
22 UIKitCore 0x00000001193e8bfd -[_UITextContainerView textContainerOrigin] + 132
23 UIFoundation 0x00007ff804532943 -[NSTextContainer textContainerOrigin] + 161
24 UIKitCore 0x00000001188d3ba9 -[_UITextLayoutBaselineCalculator _baselineOffsetAtPosition:] + 791
25 UIKitCore 0x00000001188d3dec -[_UITextLayoutBaselineCalculator firstBaselineOffsetFromTop] + 64
26 UIKitCore 0x00000001193d9f04 __37-[UITextView _baselineOffsetsAtSize:]_block_invoke + 151
27 UIKitCore 0x00000001193da2f0 __55-[UITextView _performTextKit2LayoutCalculation:inSize:]_block_invoke + 304
28 UIKitCore 0x00000001189c44e5 +[UICalloutBar performWithoutAffectingSharedCalloutBar:] + 126
29 UIKitCore 0x00000001193da19f -[UITextView _performTextKit2LayoutCalculation:inSize:] + 152
30 UIKitCore 0x00000001193d9d03 -[UITextView _baselineOffsetsAtSize:] + 504
31 UIKitCore 0x00000001193db774 -[UITextView _updateBaselineInformationDependentOnBounds] + 239
32 UIKitCore 0x00000001194e63d2 __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke_5 + 206
33 UIKitCore 0x00000001194e613c -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 991
34 UIKitCore 0x00000001194e6f00 -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 374
35 UIKitCore 0x00000001195e007e -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 346
36 UIKitCore 0x00000001195f3eb0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2413
37 QuartzCore 0x00007ff80876c054 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 526
38 UIKitCore 0x00000001195df801 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1434
39 UIKitCore 0x00000001195e6702 +[UIView(Animation) performWithoutAnimation:] + 84
40 UIKitCore 0x0000000119265f46 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 2206
41 UIKitCore 0x000000011924e209 -[UITableView _prefetchCellAtGlobalRow:aboveVisibleRange:] + 283
42 UIKitCore 0x000000011924dfd9 __48-[UITableView _configureCellPrefetchingHandlers]_block_invoke + 50
43 UIKitCore 0x00000001192a9aa8 -[_UITableViewPrefetchContext updateVisibleIndexRange:withContentOffset:] + 2577
44 UIKitCore 0x000000011924e488 -[UITableView _updateCycleIdleUntil:] + 173
45 UIKitCore 0x0000000118b02817 ___UIUpdateCycleNotifyIdle_block_invoke + 854
46 libdispatch.dylib 0x000000010a7b1da8 _dispatch_call_block_and_release + 12
47 libdispatch.dylib 0x000000010a7b2feb _dispatch_client_callout + 8
48 libdispatch.dylib 0x000000010a7c3dad _dispatch_main_queue_drain + 1463
49 libdispatch.dylib 0x000000010a7c37e8 _dispatch_main_queue_callback_4CF + 31
50 CoreFoundation 0x00007ff80037fa33 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
51 CoreFoundation 0x00007ff80037a402 __CFRunLoopRun + 2482
52 CoreFoundation 0x00007ff800379673 CFRunLoopRunSpecific + 560
53 GraphicsServices 0x00007ff809dc228e GSEventRunModal + 139
54 UIKitCore 0x0000000118fe1ac9 -[UIApplication _run] + 994
55 UIKitCore 0x0000000118fe69a0 UIApplicationMain + 123
My app only support Arabic Language. Share is working fine for other option(notes,message)
But whenever I sharing content on mail(device language is English) then alignment of subject is not correct.
If device language is Arabic then it is working fine.
I have set
UIView.appearance().semanticContentAttribute = .forceRightToLeft
in AppDelegate.
If I am changing appearance to leftRight and then to rightToLeft(for disappear) for share activity it is making app slow.
I am using segment control in my home page. When ever I am changing segment it is reloading scroll view. I am looking something like addChild or removeChild in UIKit option so that my scroll position will not change.
struct HomeListView:View {
@State private var favoriteColor = 0
var body: some View {
VStack {
Picker("What is your favorite color?", selection: $favoriteColor) {
Text("Red").tag(0)
Text("Green").tag(1)
Text("Blue").tag(2)
}
.pickerStyle(.segmented)
.padding(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
selectedView
}
.navigationBarTitleDisplayMode(.inline)
.toolbar{
ToolbarItem(placement: .navigationBarTrailing){
CustomNavigationBar()
}
ToolbarItem(placement: .navigationBarLeading){
Image(systemName: "magnifyingglass")
}
}
}
@ViewBuilder var selectedView: some View {
switch favoriteColor {
case 0:
HomeViewListing()
default:
MostPopularView()
}
}
}
struct HomeViewListing:View {
@StateObject private var viewModel = HomeViewModel()
var body: some View {
ScrollView {
LazyVStack {
ForEach(viewModel.storyItems) { item in
StoryCell(model: item)
}
}
}
.scrollIndicators(.hidden)
}
}
My App development language is only Arabic. I am using textField to Login User, whenever user long pressed, ToolTip showed up. Problem is with tool tip text it is flipped. My device language is English
After updating Xcode to version-16 and TVOS Simulator to version-18,
It started crashing at collectionview dequeue cell.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view.
Only happening with tvOS18 simulator, it is working fine with tvos17 simulator and Real Device with TvOS18.
I am trying to build my app with Xcode16 on iOS18, once app is going background PIP is enable but whenever app is coming back to foreground by tapping on PIP, black screen appears(video is playing in background). It only happening with build created by Xcode16 and running on iOS18.
It working fine with build created by Xcode15.4.
My first thought on it that somehow PIP is not stoping.