Post

Replies

Boosts

Views

Activity

AirPlay from iOS to tvOS shows black screen
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] } }
2
0
2.5k
Aug ’18
var pop not recognized; Xcode recognizes function pop()
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?
1
0
577
Jul ’22