Post not yet marked as solved
Hello,
I've implemented two functions in View controller (setupRemoteTransportControls() and setupNowPlaying()) and added one function to AppDelegate, but I'm still unable to see background audio controls of my app on the lock screen and also audio interruption function isn't working. This is the live stream from url, as you can spot on in the code. In the general settings I have added background playing:
What I would like to do is to print on the Remote Command Center artist, title and albumArt, but but i was stuck just displaying the command center. I attach link my code on github, because it is too many characters to paste it: https://github.com/pawelzet/promil_new/blob/main/ViewController.swift
Here is AppDelegate func that I've added:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
application.beginReceivingRemoteControlEvents()
// Override point for customization after application launch.
return true
}
Post not yet marked as solved
I'm parsing some data from my API and I would like to show artist and title in title section of MPMediaItemPropertyTitle and the album art. Right now I can print a string, as you can spot in the code below, but I would like to print the API data, as I'm doing it in the labels. Thank you in advance for your help. Here is my code:
import UIKit
import AVKit
import MediaPlayer
class ViewController: UIViewController, AVAudioPlayerDelegate {
var player : AVPlayer!
var dict = NSDictionary()
@IBOutlet weak var artist: UILabel!
@IBOutlet weak var songtitle: UILabel!
@IBOutlet weak var artUrl: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
overrideUserInterfaceStyle = .light
setupRemoteTransportControls()
requestNowPlaying()
setupNowPlaying()
addInterruptionsObserver()
}
[...]
//There is parsing section [...]
DispatchQueue.main.async {
self.songtitle.text = radio.nowPlaying.song.title
self.artist.text = radio.nowPlaying.song.artist
self.playlist.text = radio.nowPlaying.playlist
//albumcover art section
if let artUrl = URL(string: radio.nowPlaying.song.art),
artUrl != self.songArtUrl {
//Loading image from `artUrl`
let imageDatatask = session.dataTask(with: artUrl) { imageData, imageResponse, imageError in
if let imageError = imageError {
print(imageError)
return
}
guard let imageData = imageData else {
print("image_data is nil")
return
}
DispatchQueue.main.async {
self.songArtUrl = artUrl
let albumArt = UIImage(data: imageData)
self.artUrl.image = albumArt
}
}
imageDatatask.resume()
}
[...]
//here is some code with adding remote controls
[...]
func setupNowPlaying() {
// Define Now Playing Info
var nowPlayingInfo = [String : Any]()
nowPlayingInfo[MPMediaItemPropertyTitle] = "Here I would like to print artist + title"
nowPlayingInfo[MPMediaItemPropertyArtist] = "My name as string - nothing to change"
if let image = UIImage(named: "Deault_albumart") { //Here I would like to add image from API
nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { size in
return image
}
}
nowPlayingInfo[MPNowPlayingInfoPropertyIsLiveStream] = true
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
}
My app uses the Media Player framework to play music and has the Audio background mode. When a user pauses the music and backgrounds the app (or if the app is already in the background when they pause), the system does not kill the app as long as it has the active AVAudioSession. This means that as long as a user doesn't start playback from another audio app, mine is available in Control Center for a quick resume.
I recently implemented the UIBackgroundTask API (specifically UIApplication.shared.beginBackgroundTask/endBackgroundTask) to run a 5-20 second server communication task when the app is paused while in the background. Now, iOS kills my app at the conclusion of that task, despite it still having the active audio session. It is no longer in Control Center, and needs to be launched fresh.
Is there anything I can do to prevent the system from killing my app at the conclusion of the background task? I'm starting to get complaints from users that they're having to relaunch the app after every time they pause for more than a few seconds.
Thanks!
Post not yet marked as solved
I don't know why but when I go into MusicKit part on developer part on my app on Apple's website there is no spot to configure it. I saw online a lot of articles saying that you have to configure it to use MusicKit with an app. Is this a bug or something or do I need to do something to enable it? I just don't understand I added it into my app but I can't seem to get this to work for some reason I'm not sure why.
Post not yet marked as solved
As the title asks, is it possible to support SharePlay using the applicationQueuePlayer in the Media Player framework? It seems not to be possible since there is no AVPlaybackCoordinator available like there is for AVPlayer.
Is that correct? It would be nice to be able to support this in my application if possible. Thanks!
Post not yet marked as solved
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001b7fb8204 __ulock_wait + 8
1 libdispatch.dylib 0x00000001811df344 _dlock_wait + 56 (lock.c:326)
2 libdispatch.dylib 0x00000001811df0e8 _dispatch_thread_event_wait_slow + 56 (lock.c:366)
3 libdispatch.dylib 0x00000001811edd58 DISPATCH_WAIT_FOR_QUEUE + 364 (lock.h:330)
4 libdispatch.dylib 0x00000001811ed900 _dispatch_sync_f_slow + 144 (queue.c:1762)
5 MediaToolbox 0x000000018b59f414 playerasync_CopyProperty + 516 (FigPlayer_Async.c:3014)
6 AVFCore 0x000000018a8e5488 -[AVPlayer _timeControlStatusAndWaitingReason:] + 244 (CMBaseObject.h:396)
7 AVFCore 0x000000018a8b1f9c __avplayer_fpNotificationCallback_block_invoke + 888 (AVPlayer.m:7940)
8 libdispatch.dylib 0x00000001811dcc04 _dispatch_call_block_and_release + 32 (init.c:1516)
9 libdispatch.dylib 0x00000001811de950 _dispatch_client_callout + 20 (object.m:560)
10 libdispatch.dylib 0x00000001811ecd30 _dispatch_main_queue_callback_4CF + 940 (inline_internal.h:2597)
11 CoreFoundation 0x0000000181524ce4 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 (CFRunLoop.c:1795)
12 CoreFoundation 0x00000001814deebc __CFRunLoopRun + 2540 (CFRunLoop.c:3144)
13 CoreFoundation 0x00000001814f23c8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
14 GraphicsServices 0x000000019cd0338c GSEventRunModal + 164 (GSEvent.c:2200)
15 UIKitCore 0x0000000183e98060 -[UIApplication _run] + 1100 (UIApplication.m:3457)
16 UIKitCore 0x0000000183c15b8c UIApplicationMain + 2124 (UIApplication.m:5013)
17 BanBanLive 0x0000000100be3e38 main + 88 (main.m:13)
18 dyld 0x0000000103589a24 start + 520 (dyldMain.cpp:876)
Post not yet marked as solved
Is there a way to get the current queue items from an MPMusicPlayerController?
I need to know when the items I've set to the queue finish playing completely but cannot find any way to do this.
I am not using MusicKit but setting the queue via play parameters.
From what I can tell so far, after the queue finishes playing, it pauses and resets to the first item in the queue. So even after playback is done, there is no way to know that it finished on its own.
Post not yet marked as solved
Hello everyone I'm seeing weird crash on bugsnag.
Its about player on tvOS and it happens when I'm exiting player.
And its 2 system classes.
Can someone help me understand what's going on here
Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x2831d5480 "AVFocusProxyView:0x1224b3370.left"> and <NSLayoutXAxisAnchor:0x28356cf40 "AVPlayerLayerView:0x1224bf9b0.left"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.
Post not yet marked as solved
When I try to play music through my built in speakers it automatically goes through my TV, I don't want it to so I tried going through Sounds and changing the settings but I can't stop it doing it, any ideas please?
Post not yet marked as solved
Crashed: com.apple.MediaPlayer.MPNowPlayingInfoCenter/accessQueue
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000001dd4a68
Post not yet marked as solved
When the player's rate is being set to a different value than 1.0 I am experiencing after a few seconds issues with handling different remote commands.
In my case when I change the rate e.g. to 3.0 after a little time only remoteCenter.playCommand's handle is triggered. Even when the player still plays. The handlers return .success after the block content is successfully executed. All relevant commands are enabled (command.isEnabled).
The properties of MPRemoteCommandCenter are pretty simple so there is a little space to adjust it.
I have tried to toggle the isEnabled value on different commands.
Explicitly called unregisterForRemoteNotifications, registerForRemoteNotifications on UIApplication
Tested the case only with the playCommand, and pauseCommand.
Used the older API with selectors
Nothing of this has helped.
let remoteCenter = MPRemoteCommandCenter.shared()
remoteCenter.playCommand.addTarget { [weak self] _ in ...
Post not yet marked as solved
Version: 14.x
Setting videoGravity of AVSampleBufferDisplayLayer does not work, however, when I change bounds of this layer, it worked, is this a bug or feature?
but in iOS 15, this propery worked well.
Post not yet marked as solved
I don't know how to take out SUBTITLE file.
Post not yet marked as solved
I am able to play AES encrypted content in online mode and download it . But the downloaded content does not play in offline mode.
Steps:
Get encrypted content url
call backend api to get token to decrypt the url
play the content . works
download content. works
off the internet and try to play . Fails to play.
Post not yet marked as solved
EarPods toggle button event has been received on iPhone 7.
But it hasn't happened since yesterday. The source code has never been changed.
The source code is roughly like this.
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.togglePlayPauseCommand addTarget:self action:@selector(onTogglePlayPause:)];
commandCenter.togglePlayPauseCommand.enabled = 1;
- (MPRemoteCommandHandlerStatus)onTogglePlayPause:(MPRemoteCommandHandlerStatus*)event {
NSLog(@"toggle event! - never called....");
return MPRemoteCommandHandlerStatusSuccess;
}
env
iphone 7 (ios 15.2)
xcode 13.1
How do I get this event?
Post not yet marked as solved
I have a MUSIC website that uses the BetterAudioPlaylist front-end HTML5 player (https://github.com/NelsWebDev/BetterAudioPlaylist).
For over 2 years it has worked flawlessly on my iPhone, however when I updated to iOS 12.1 it no longer advances to the next audio file if the screen is locked.
I have tried going into Safari settings and used my troubleshooting skills to verify it has nothing to do with my settings.
Is this Apple pushing out the little guy in favor of iTunes?
Has anyone else had this problem? I contacted Apple's Developers support email, however they never responded.
Please help!
Post not yet marked as solved
Attempting to pull a podcast, via it's ID, leads to a CORS error, as it has the response header:
access-control-allow-origin: http://localhost:3000
Meaning, locally, I am able to pull the required podcast episode list, but as soon as I am in staging or production, the whole thing falls over.
Has anyone come across this issue, and does anyone have any work arounds?
Post not yet marked as solved
Hello,
https://stackoverflow.com/questions/51797343/setting-http-header-fields-for-avurlassets
Is it okay to use the method using "AVURLAssetHTTPHeaderFieldsKey" described on this page?
Post not yet marked as solved
iTunesMetadataTrackSubTitle value showing within quotes in tvOS player inside info tab, can we avoid this double quotes
Post not yet marked as solved
Hi,
We have a Video Player App, which seem to crash randomly when player is closed.
Crash Info:
crash_info_entry_0 : BUG IN CLIENT OF LIBDISPATCH: dispatch_sync called on queue already owned by current thread
Stack trace:
0 libdispatch.dylib 0x12dd0 __DISPATCH_WAIT_FOR_QUEUE__ + 484
1 libdispatch.dylib 0x12900 _dispatch_sync_f_slow + 144
2 MediaToolbox 0x1f6374 FigCaptionRendererSessionSetPlayer + 68
3 MediaToolbox 0x2a7b30 setPlayerDo + 184
4 libdispatch.dylib 0x3950 _dispatch_client_callout + 20
5 libdispatch.dylib 0x12a70 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6 MediaToolbox 0x2a7a6c -[FigSubtitleCALayer setPlayer:] + 64
7 AVFCore 0x6e2c0 -[AVPlayer _removeLayer:videoLayer:closedCaptionLayer:subtitleLayer:interstitialLayer:] + 572
8 AVFCore 0x30dc8 -[AVPlayerLayer dealloc] + 324
9 Foundation 0x2cf78 NSKVODeallocate + 216
10 QuartzCore 0x68c54 CA::Layer::free_transaction(CA::Transaction*) + 404
11 QuartzCore 0x4f284 CA::Transaction::commit() + 952
12 MediaToolbox 0x3375bc setBounds + 376
13 MediaToolbox 0x200160 UpdateLayoutContext + 892
14 MediaToolbox 0x1feda8 onCaptionInputDo + 212
15 libdispatch.dylib 0x3950 _dispatch_client_callout + 20
16 libdispatch.dylib 0xb0ac _dispatch_lane_serial_drain + 664
17 libdispatch.dylib 0xbc10 _dispatch_lane_invoke + 392
18 libdispatch.dylib 0x16318 _dispatch_workloop_worker_thread + 656
19 libsystem_pthread.dylib 0x11b0 _pthread_wqthread + 288
20 libsystem_pthread.dylib 0xf50 start_wqthread + 8