【问题标题】:Invalid asset name supplied: '(null)'提供的资产名称无效:'(null)'
【发布时间】:2018-03-15 15:27:07
【问题描述】:

我正在尝试制作一个 iPhone 应用程序,您可以在其中按下按钮,然后通过 MAMP 将视频从我的 mac 流式传输到手机。当我点击按钮时,播放器会显示,但视频无法播放,并且出现此错误。

2018-03-15 10:19:30.487597-0500 stream[5956:2522500] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    "r_Attributes" = 1;
    sync = syna;
}
2018-03-15 10:19:30.644950-0500 stream[5956:2522500] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None (client: stream)
2018-03-15 10:19:30.714388-0500 stream[5956:2522500] [framework] CUICatalog: Invalid asset name supplied: '(null)'
2018-03-15 10:19:30.714440-0500 stream[5956:2522500] [framework] CUICatalog: Invalid asset name supplied: '(null)'
2018-03-15 10:19:30.763593-0500 stream[5956:2522500] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_Presence (client: stream)
2018-03-15 10:19:30.846707-0500 stream[5956:2522500] [framework] CUICatalog: Invalid asset name supplied: '(null)'
2018-03-15 10:19:30.846763-0500 stream[5956:2522500] [framework] CUICatalog: Invalid asset name supplied: '(null)'

这里是完整的代码:

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {
    @IBAction func playVideo(_ sender: Any) {
        guard let url = URL(string: "http://host-2:8888/The Serenity Trance Sample Pack (138 bpm Loops, Vocals, Drums, Snares, Presets, and more!).m3u8") else {
            return
        }
        // Create an AVPlayer, passing it the HTTP Live Streaming URL.
        let player = AVPlayer(url: url)

        // Create a new AVPlayerViewController and pass it a reference to the player.
        let controller = AVPlayerViewController()
        controller.player = player

        // Modally present the player and call the player's play() method when complete.
        present(controller, animated: true) {
            player.play()
        }
    }
}

【问题讨论】:

    标签: ios swift http mamp avplayer


    【解决方案1】:

    问题在于您的 URL 字符串未编码,因此 URLnil 并且您的函数从 guard 语句的主体返回。

    guard let encodedUrlString = "http://host-2:8888/The Serenity Trance Sample Pack (138 bpm Loops, Vocals, Drums, Snares, Presets, and more!).m3u8".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let url = URL(string: encodedUrlString) else {     
        print("Invalid URL")
        return
    }
    

    【讨论】:

    • 谢谢大卫 它至少现在尝试检索视频,但我仍然遇到同样的错误。这可能与我的连接有关吗?
    • 即使视频播放正常,这些消息也会出现在控制台中,因此很可能不是问题所在。例如,是否可以在浏览器中从该 URL 播放相同的视频,您是否只在从 AVPlayer 播放时遇到问题?
    • 当我使用 mp4 版本的视频时,它可以在浏览器中正常播放。但是 m3u8 和 mp4 都不能在我的手机上播放。
    • 您正在使用http 连接,您是否将必要的密钥添加到您的Info.plist 文件以使iOS 允许不安全的连接?如果你不知道怎么做,请查看this Q&A。
    • 是的,我也这样做了。
    猜你喜欢
    • 1970-01-01
    • 2014-12-17
    • 2023-03-13
    • 2014-10-26
    • 2014-06-09
    • 1970-01-01
    • 2020-07-15
    • 2016-01-26
    • 1970-01-01
    相关资源
    最近更新 更多