使用HTTP Live Streaming的备用音轨 [英] Alternate audio tracks with HTTP Live Streaming

查看:89
本文介绍了使用HTTP Live Streaming的备用音轨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当HLS流准备好播放时,我正在生成可用音轨的列表.我可以很好地访问可用的音轨,但是我很难为每个音轨提取正确的标题".

I'm generating a list of available audio tracks when an HLS stream is ready to play. I can access the available audio tracks just fine, but I'm having difficulty extracting the correct 'Title' for each track.

我正在使用 Apple的测试流有两个音轨.我用这个来提取曲目...

I'm using Apple's test stream which has two audio tracks. I extract the tracks with this...

availableAudioTrackList = [[NSMutableArray alloc] init];
AVMediaSelectionGroup *audioTracks = [player.currentItem.asset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicAudible];
for (int i = 0; i < [audioTracks.options count]; i++) {
    AVMediaSelectionOption *opt = audioTracks.options[i];
    NSLog(@"Opt: %@", opt);
    [availableAudioTrackList insertObject:opt.displayName atIndex:i];
}
NSLog(@"Audio Track Array: %@", availableAudioTrackList);

我的输出显示'opt.displayName'没有给出BipBop Audio 1和BipBop Audio 2的标题(这些是我想使用的区分名称).

My output shows that 'opt.displayName' does not give the title of BipBop Audio 1 and BipBop Audio 2 (these are the distinguishing names I want to be able to use).

... Opt: <AVMediaSelectionKeyValueOption: 0x15dad0d0, locale = en, mediaType = 'soun', title = BipBop Audio 1, default = YES> 
... Opt: <AVMediaSelectionKeyValueOption: 0x15dad100, locale = en, mediaType = 'soun', title = BipBop Audio 2>

...Audio Track Array: ( English, English )

您知道如何/是否可以从AVMediaSelectionOption对象中提取标题吗?

Any idea how/if I can extract the title from the AVMediaSelectionOption object?

谢谢!

推荐答案

您必须按照以下说明从元数据中获取

You have to fetch it from metadata as follows

    NSArray *metaDatas = [AVMetadataItem metadataItemsFromArray:opt.commonMetadata withKey:@"title" keySpace:@"comn"];
    if (metaDatas.count > 0) {
      NSString *title = ((AVMetadataItem*)[metaDatas objectAtIndex:0]).stringValue;
      NSLog(@"title: %@", title);
    }

这篇关于使用HTTP Live Streaming的备用音轨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆