Commit 3dc76668 authored by Steven杜宇's avatar Steven杜宇

// 解决静音模式下播放视频无声音问题

parent 3cdd4604
...@@ -18,6 +18,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate { ...@@ -18,6 +18,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
setupAudionConfig()
//初始化 神策sdk //初始化 神策sdk
YHAnalytics.analyticsStart(launchOptions: launchOptions) YHAnalytics.analyticsStart(launchOptions: launchOptions)
...@@ -157,6 +159,18 @@ extension AppDelegate { ...@@ -157,6 +159,18 @@ extension AppDelegate {
player?.pause() player?.pause()
} }
} }
private func setupAudionConfig() {
// 确保 AVAudioSession 被正确配置,以便在静音模式下也能正常播放音频
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
try AVAudioSession.sharedInstance().setActive(true)
} catch let error as NSError {
print("error: \(error.localizedDescription)")
}
}
} }
...@@ -57,7 +57,7 @@ class YHUserInfoHeaderView: UIView { ...@@ -57,7 +57,7 @@ class YHUserInfoHeaderView: UIView {
private lazy var likeLabel:UILabel = { private lazy var likeLabel:UILabel = {
let label = UILabel() let label = UILabel()
label.text = "点赞 0".local label.text = "点赞 0".local
label.textColor = UIColor(hex: 0x949DB5) label.textColor = UIColor(hex: 0x121A26, transparency: 0.5)
label.textAlignment = NSTextAlignment.left label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13) label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true label.isUserInteractionEnabled = true
...@@ -70,7 +70,7 @@ class YHUserInfoHeaderView: UIView { ...@@ -70,7 +70,7 @@ class YHUserInfoHeaderView: UIView {
private lazy var collectLabel:UILabel = { private lazy var collectLabel:UILabel = {
let label = UILabel() let label = UILabel()
label.text = "收藏 0".local label.text = "收藏 0".local
label.textColor = UIColor(hex: 0x949DB5) label.textColor = UIColor(hex: 0x121A26, transparency: 0.5)
label.textAlignment = NSTextAlignment.left label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13) label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true label.isUserInteractionEnabled = true
...@@ -83,7 +83,7 @@ class YHUserInfoHeaderView: UIView { ...@@ -83,7 +83,7 @@ class YHUserInfoHeaderView: UIView {
private lazy var scanLabel:UILabel = { private lazy var scanLabel:UILabel = {
let label = UILabel() let label = UILabel()
label.text = "最近浏览 0".local label.text = "最近浏览 0".local
label.textColor = UIColor(hex: 0x949DB5) label.textColor = UIColor(hex: 0x121A26, transparency: 0.5)
label.textAlignment = NSTextAlignment.left label.textAlignment = NSTextAlignment.left
label.font = UIFont.PFSC_R(ofSize: 13) label.font = UIFont.PFSC_R(ofSize: 13)
label.isUserInteractionEnabled = true label.isUserInteractionEnabled = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment