gpt4 book ai didi

ios - 如何去除 CarPlay ListView 中的云图标?

转载 作者:可可西里 更新时间:2023-11-01 01:50:11 25 4
gpt4 key购买 nike

有谁知道如何从 CarPlay 的 ListView 中删除小云图标?我附上了它的截图。这些电台只能直播,不可下载。我还将代码包含在我的 Carplay-AppDelegate、CarPlay-Playlist 和 CarPlay-StationList 中。谢谢

enter image description here

CARPLAY-APPDELEGATE 代码:

import Foundation
import MediaPlayer

extension AppDelegate {

func setupCarPlay() {
playableContentManager = MPPlayableContentManager.shared()

playableContentManager?.delegate = self
playableContentManager?.dataSource = self

stationsViewController?.setupRemoteCommandCenter()
stationsViewController?.updateLockScreen(with: nil)
}
}

extension AppDelegate: MPPlayableContentDelegate {

func playableContentManager(_ contentManager: MPPlayableContentManager, initiatePlaybackOfContentItemAt indexPath: IndexPath, completionHandler: @escaping (Error?) -> Void) {

DispatchQueue.main.async {
UIApplication.shared.beginReceivingRemoteControlEvents()

if indexPath.count == 2 {
let station = self.carplayPlaylist.stations[indexPath[1]]
self.stationsViewController?.selectFromCarPlay(station)
}
completionHandler(nil)

// Workaround to make the Now Playing working on the simulator:
// Source: https://stackoverflow.com/questions/52818170/handling-playback-events-in-carplay-with-mpnowplayinginfocenter
// UIApplication.shared.endReceivingRemoteControlEvents()
// UIApplication.shared.beginReceivingRemoteControlEvents()
}
}

func beginLoadingChildItems(at indexPath: IndexPath, completionHandler: @escaping (Error?) -> Void) {
carplayPlaylist.load { error in
completionHandler(error)
}
}
}

extension AppDelegate: MPPlayableContentDataSource {

func numberOfChildItems(at indexPath: IndexPath) -> Int {
if indexPath.indices.count == 0 {
return 1
}

return carplayPlaylist.stations.count
}

func contentItem(at indexPath: IndexPath) -> MPContentItem? {

if indexPath.count == 1 {
// Tab section
let item = MPContentItem(identifier: "Stations")
item.title = "Stations"
item.isContainer = true
item.isPlayable = false
item.artwork = MPMediaItemArtwork(boundsSize: #imageLiteral(resourceName: "carPlayTab").size, requestHandler: { _ -> UIImage in
return #imageLiteral(resourceName: "carPlayTab")
})
return item
} else if indexPath.count == 2, indexPath.item < carplayPlaylist.stations.count {

// Stations section
let station = carplayPlaylist.stations[indexPath.item]

let item = MPContentItem(identifier: "\(station.name)")
item.title = station.name
item.subtitle = station.desc
item.isPlayable = true
item.isStreamingContent = true

if station.imageURL.contains("http") {
ImageLoader.sharedLoader.imageForUrl(urlString: station.imageURL) { image, _ in
DispatchQueue.main.async {
guard let image = image else { return }
item.artwork = MPMediaItemArtwork(boundsSize: image.size, requestHandler: { _ -> UIImage in
return image
})
}
}
} else {
if let image = UIImage(named: station.imageURL) ?? UIImage(named: "stationImage") {
item.artwork = MPMediaItemArtwork(boundsSize: image.size, requestHandler: { _ -> UIImage in
return image
})
}
}

return item
} else {
return nil
}
}
}

CARPLAY-播放列表代码:

import Foundation

class CarPlayPlaylist {

var stations = [RadioStation]()

func load(_ completion: @escaping (Error?) -> Void) {

DataManager.getStationDataWithSuccess() { (data) in

guard let data = data else {
completion(nil)
return
}

do {
let jsonDictionary = try JSONDecoder().decode([String: [RadioStation]].self, from: data)
if let stationsArray = jsonDictionary["station"] {
self.stations = stationsArray
}
} catch (let error) {
completion(error)
return
}

completion(nil)
}

}

}

CARPLAY-STATIONLIST 代码:

import UIKit

extension StationsViewController {
func selectFromCarPlay(_ station: RadioStation) {
radioPlayer.station = station
handleRemoteStationChange()
}
}

最佳答案

云图标的存在取决于 isStreamingContent 的值。

关于ios - 如何去除 CarPlay ListView 中的云图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55106889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com