Skip to content

切换清晰度

changsanjiang edited this page Dec 10, 2020 · 2 revisions

以下为通用的切换清晰度的方法, 针对 AliPlayer 的 trackInfos 方式的切换请前往如何获取 AliPlayer 的 trackInfos 以及怎样切换这些 track ?查看.

1. 设置对应的清晰度资源

当设置definitionURLAssets后, 控制层上将显示切换清晰度的按钮.

/// 以下为设置 SJVideoPlayer.definitionURLAssets, 将会在清晰度切换控制层中显示这些资源项. 

SJVideoPlayerURLAsset *asset1 = [[SJVideoPlayerURLAsset alloc] initWithURL:VideoURL_Level4];
asset1.definition_fullName = @"超清 1080P";
asset1.definition_lastName = @"超清";

SJVideoPlayerURLAsset *asset2 = [[SJVideoPlayerURLAsset alloc] initWithURL:VideoURL_Level3];
asset2.definition_fullName = @"高清 720P";
asset2.definition_lastName = @"AAAAAAA";

SJVideoPlayerURLAsset *asset3 = [[SJVideoPlayerURLAsset alloc] initWithURL:VideoURL_Level2];
asset3.definition_fullName = @"清晰 480P";
asset3.definition_lastName = @"480P";

_player.definitionURLAssets = @[asset1, asset2, asset3];

2. 选择一个清晰度进行播放, 后续用户选择其他清晰度后, 播放器会进行切换处理

// 先播放asset1. (asset2 和 asset3 将会在用户选择后进行切换)
_player.URLAsset = asset1;
Clone this wiki locally