iOS Chromecast:从 HLS 播放列表读取时长

iOS Chromecast: Read Duration from HLS Playlist

我有一个长片的 m3u8 播放列表:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:3
#EXTINF:2.987,
https://...segment0.ts
#EXTINF:2.987,
https://...segment1.ts
#EXTINF:2.987,
https://...segment2.ts
...

带有标签 #EXT-X-PLAYLIST-TYPE:VOD,关于 Apple says:

For Video on Demand (VOD) sessions, media files are available representing the entire duration of the presentation. The index file is static and contains a complete list of URLs to all media files created since the beginning of the presentation. This kind of session allows the client full access to the entire program.

当我将此播放列表流式传输到 iOS 本机播放器或其他自定义 iOS 播放器时,播放器会确定内容的总持续时间并显示它。

现在我正在尝试投射相同的媒体,而 Chromecast 似乎不知道总时长。我连接了 GCKUIMediaController 和 UILabels 以及所有爵士乐,但播放器将播放列表视为直播,显示总持续时间 --:--

如何让 Chromecast 从 HLS 播放列表中读取总时长?[​​=42=]

这是我在我的 iOS 发件人应用程序中加载此项目的方式:(或多或少)

let metadata = GCKMediaMetadata(metadataType: .movie)
metadata.setString("Blah", forKey: kGCKMetadataKeyTitle)

let mediaInfo = GCKMediaInformation(contentID: URL(string: "https://blah.m3u8"), streamType: GCKMediaStreamType.buffered, contentType: contentType, metadata: metadata, streamDuration: 0, mediaTracks: nil, textTrackStyle: GCKMediaTextTrackStyle.createDefault(), customData: nil)

let builder = GCKMediaQueueItemBuilder()
builder.mediaInformation = mediaInfo
builder.preloadTime = 10.0
builder.playbackDuration = .infinity

let item = builder.build()
item.clearItemID()

let rmc = GCKCastContext.sharedInstance().sessionManager.currentCastSession.remoteMediaClient
rmc.queueLoad([item], start: 0, playPosition: TimeInterval(0.0), repeatMode: .off, customData: nil)

我找到的一些文档:

builder.playbackDuration = .infinity

The playback duration for the item, in seconds, or INFINITY if the stream's actual duration should be used. (So, should be set correctly.)

GCKMediaStreamType.buffered

A buffered stream type. (Not sure what this does, but I'm not setting it to .live at least.)

streamDuration: 0

The length of the stream, in seconds, or INFINITY if it is a live stream. Defaults to 0. Seems like the reverse of playbackDuration on the QueueItemBuilder? I set this to zero.

我缺少什么设置才能让 Chromecast 从我的 HLS 流视频中读取持续时间?

问题显然出在我使用的 Styled Media Receiver 上:

Version note: The Receiver API and Media Player Library are based on Cast SDK v2 and are compatible with both v2 and CAF senders.

当我切换到 Default Media Receiver 时,这个问题就消失了;我能够在 VOD HLS 流上看到持续时间。

我了解到此类信息已通过 Chromecast 设备中的接收器应用程序 运行 暴露给 iOS Cast SDK。我想 Styled Receiver 没有内置的功能来计算 HLS 播放列表的持续时间。