【问题标题】:Get the duration of .m3u audio获取 .m3u 音频的时长
【发布时间】:2021-07-16 18:28:58
【问题描述】:

我想通过 URL 播放音频 https://wortcast01.wortfm.org/appfiles/wort_210715_080006buzzthu.m3u

它有一个身体(有轨道)

https://wortcast01.wortfm.org/pitch/preroll-buzzthu.mp3
https://wortcast01.wortfm.org/mp3/wort_210715_080006buzzthu.mp3

当我将https://wortcast01.wortfm.org/appfiles/wort_210715_080006buzzthu.m3u 设置为 AVPlayer 时,持续时间等于 Nan。但是列表中的每个曲目都有一个持续时间。

您知道如何通过 AVPlayer 提取持续时间吗?

回南:

var itemDuration: Double? {
    return currentItem?.duration.seconds
}

【问题讨论】:

  • 显示您打开和播放音频的代码行。

标签: swift avplayer


【解决方案1】:

AVFoundation(AVPlayer, AVAsset....) 自动将任何 .m3u 标记为“直播”(我的假设:看起来 Apple 使用场景 M3U8 来处理 M3U) 解决方案: 创建加载 m3u(或 pls)内容的附加功能,创建内部播放列表,并在 AVPlayer 中播放这些内部部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    相关资源
    最近更新 更多