Skip to content

Commit

Permalink
feat: 添加preferavc开关,低性能设备启用后减少播放卡顿掉帧
Browse files Browse the repository at this point in the history
  • Loading branch information
yichengchen committed Jul 8, 2023
1 parent c1693fd commit 0407d53
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ class BilibiliVideoResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelega
reset()
hasSubtitle = subtitles.count > 0
var videos = info.dash.video
if Settings.preferHevc {
if videos.contains(where: { $0.isHevc }) {
videos.removeAll(where: { !$0.isHevc })
if Settings.preferAvc {
if videos.contains(where: { !$0.isHevc }) {
videos.removeAll(where: { $0.isHevc })
}
}

Expand Down
4 changes: 2 additions & 2 deletions BilibiliLive/Component/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ enum Settings {
@UserDefault("Settings.losslessAudio", defaultValue: false)
static var losslessAudio: Bool

@UserDefault("Settings.preferHevc", defaultValue: false)
static var preferHevc: Bool
@UserDefault("Settings.preferAvc", defaultValue: false)
static var preferAvc: Bool

@UserDefault("Settings.defaultDanmuStatus", defaultValue: true)
static var defaultDanmuStatus: Bool
Expand Down
4 changes: 2 additions & 2 deletions BilibiliLive/Module/Personal/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ class SettingsViewController: UIViewController {
}
cellModels.append(losslessAudio)

let hevc = CellModel(title: "Hevc优先", desp: Settings.preferHevc ? "" : "") {
let hevc = CellModel(title: "Avc优先(卡顿尝试开启)", desp: Settings.preferAvc ? "" : "") {
[weak self] in
Settings.preferHevc.toggle()
Settings.preferAvc.toggle()
self?.setupData()
}
cellModels.append(hevc)
Expand Down

0 comments on commit 0407d53

Please sign in to comment.