When I stream a audio-stream from iOS to tvOS it works, but shows the black screen (mirrorring or video screen I think). What do I have to do to tell tvOS that it's audio and therefore it shows the title, artist and image in the left top corner?I use AVPlayer (this is my ViewDidLoad)://0. Become first responder
UIApplication.shared.becomeFirstResponder()
//1. Set up the session
radioAudioSession = AVAudioSession.sharedInstance()
NotificationCenter.default.addObserver(self, selector: #selector(AVAudioSessionInterruption(_:)), name: NSNotification.Name.AVAudioSessionInterruption, object: nil)
//2. Choose and set category
do {try radioAudioSession.setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm)}
catch {print("An Error occured setting catergory the audio session: \(error)")}
do {try radioAudioSession.setActive(true, with: [])}
catch {print("An Error occured activating the audio session: \(error)")}
//3. Set AVPlayer
radioAVPlayer = AVPlayer.init(playerItem: radioAVPlayerItem)
//4. Handle interruptions -> zie @objc func AVAudioSessionInterruption ...
radioAVPlayerItem.addObserver(self, forKeyPath: "timedMetadata", options: NSKeyValueObservingOptions(), context: nil)
radioAVPlayer.addObserver(self, forKeyPath: "rate", options: NSKeyValueObservingOptions(), context: nilThis is my update-function for NowPlayingInfo:func updateNowPlayingInfo (withRadiostation: [String], title: String?, artist: String?) {
//bij title en artist = nil dan is er geen songinformatie beschikbaar in de stream
let radioName = withRadiostation[0]
let radioSlogan = withRadiostation[1]
radioURL = URL.init(string: withRadiostation[2])
let radioImage = UIImage(named: withRadiostation[3])!
nowPlaying.text = radioName
let radioArtwork = MPMediaItemArtwork.init(boundsSize: radioImage.size, requestHandler: { (size) -> UIImage in
return radioImage})
if title == nil || artist == nil || (title?.isEmpty)! || (artist?.isEmpty)! {
//MPMediaItemPropertyAssetURL: radioURL!
audioInfo.nowPlayingInfo = [MPMediaItemPropertyTitle: radioName, MPMediaItemPropertyArtist: radioSlogan, MPNowPlayingInfoPropertyIsLiveStream: true, MPMediaItemPropertyMediaType: MPNowPlayingInfoMediaType.audio.rawValue, MPMediaItemPropertyArtwork: radioArtwork]
} else {
//MPMediaItemPropertyAssetURL: radioURL!
audioInfo.nowPlayingInfo = [MPMediaItemPropertyTitle: title as Any, MPMediaItemPropertyArtist: artist as Any, MPNowPlayingInfoPropertyIsLiveStream: true, MPMediaItemPropertyMediaType: MPNowPlayingInfoMediaType.audio.rawValue, MPMediaItemPropertyArtwork: radioArtwork]
}
}
Post
Replies
Boosts
Views
Activity
Are there more developers noticing that metadata is not working on iOS 16 beta 1 and 2? Both possible solutions are not working:
observeValue for key "timedMetadata" and
AVPlayerItemMetadataOutputPushDelegate.
The code I produced works fine on iOS 16 in the simulator, but not on a real device (iPhone XR).
In mij project I use a var pop = [[String]] with popmusic radiostations. The var is declared in a separate file.
var pop2 = [dobbelsteen, spice, achttienHits, tweefm, axl, dolfijnfmtop40, glowFM, haarlem105, heteHits, jey, megahitFM, nonstoptop40, radio3, qmusicnl, qmusicnltop40, radio538, radio538Top50, skyradiolive, todaysHitradio, wildFM]
Using that var in iOS code works ...
lijstGeselecteerd = pop
but using it in watchOS gives the following error: Cannot assign value of type '() -> Void' to type '[[String]]'. Xcode thinks I refer to the function pop(). But I want to refer to de var pop.
Is it possible to refer explicitly to the var?
Is it possible to change the font and/or font size of WKInterfacePicker and it's WKPickerItems?
Is it possible to create an own volume controle like in the NowPlaying screen?
I can use a slides, but that's a horizontal one. I like to use a vertical one. Is that possible?
I made a widget for my iOS app. It works fine. Now I'm porting it to my macOS app, but somehow the widget configuration is not working. The items are shown but I'm not able to select them somehow.
See a screenshot, but please take a look at the video I made: https://youtu.be/6FtBvFQV_1kshowing the problem.
Has anyone any clue what's going wrong here?