-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor the commonplayerViewController and remove subclassing …
…AVPlayerViewController (#109) * tmp: add NewCommonPlayerViewController * feat: add plugins * feat: support pip * feat: add playlist and speed changer plugin * feat: live use new player * remove old commonPlayer * 添加港澳台解锁支持 * misc: rename NewCommonPlayerViewController.swift * 修复投屏
- Loading branch information
1 parent
be8dce4
commit 5875f08
Showing
33 changed files
with
1,647 additions
and
849 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
BilibiliLive.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AVPlayerMetaUtils.swift | ||
// BilibiliLive | ||
// | ||
// Created by yicheng on 2024/6/6. | ||
// | ||
|
||
import AVKit | ||
import Kingfisher | ||
|
||
enum AVPlayerMetaUtils { | ||
static func setPlayerInfo(title: String?, subTitle: String?, desp: String?, pic: URL?, player: AVPlayer) async { | ||
let desp = desp?.components(separatedBy: "\n").joined(separator: " ") | ||
let mapping: [AVMetadataIdentifier: Any?] = [ | ||
.commonIdentifierTitle: title, | ||
.iTunesMetadataTrackSubTitle: subTitle, | ||
.commonIdentifierDescription: desp, | ||
] | ||
var metas = mapping.compactMap { createMetadataItem(for: $0, value: $1) } | ||
|
||
player.currentItem?.externalMetadata = metas | ||
|
||
if let pic = pic, | ||
let resource = try? await KingfisherManager.shared.retrieveImage(with: Kingfisher.ImageResource(downloadURL: pic)), | ||
let data = resource.image.pngData(), | ||
let item = createMetadataItem(for: .commonIdentifierArtwork, value: data) | ||
{ | ||
metas.append(item) | ||
player.currentItem?.externalMetadata = metas | ||
} | ||
} | ||
|
||
static func createMetadataItem(for identifier: AVMetadataIdentifier, value: Any?) -> AVMetadataItem? { | ||
if value == nil { return nil } | ||
let item = AVMutableMetadataItem() | ||
item.identifier = identifier | ||
item.value = value as? NSCopying & NSObjectProtocol | ||
// Specify "und" to indicate an undefined language. | ||
item.extendedLanguageTag = "und" | ||
return item.copy() as? AVMetadataItem | ||
} | ||
} |
Oops, something went wrong.