gpt4 book ai didi

ios - AVPlayer 音频静音

转载 作者:行者123 更新时间:2023-11-29 12:09:33 28 4
gpt4 key购买 nike

我是 Xcode 的新手,请帮助我。我在 IOS 应用程序的 View Controller 中添加了 AVPlayer。它在 View 中显示视频但没有音频。任何帮助任何人提前谢谢

最佳答案

你的音频是静音的原因是你可能没有初始化 AVAudioSession 检查这个..

 AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];


UIView *myView = previewView;

videoController = [[MPMoviePlayerViewController alloc]initWithContentURL:videoPlayUrl];
videoController.view.frame = myView.bounds;

[videoController.view setBounds:previewView.bounds];
videoController.moviePlayer.controlStyle = MPMovieControlStyleNone;
videoController.moviePlayer.scalingMode = MPMovieScalingModeFill;
videoController.moviePlayer.shouldAutoplay = NO;
videoController.view.clipsToBounds = YES;
[previewView.layer addSublayer:videoController.view.layer];

[videoController.moviePlayer prepareToPlay];

关于ios - AVPlayer 音频静音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33915672/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com