- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
很抱歉我的问题,但我实现了一个介绍视频,尽管我的 iPad 有硬件静音开关,但音频仍在播放。我也在我的应用程序中使用 AVAudioplayer 来播放简短的声音样本。在这个类中,它是我设置“AVAudioSessionCategory”的唯一区域。但仅对于所有音频播放,听不到任何声音。它仅用于我的介绍视频。
对于如何修复“音频错误”以使电影播放器保持静音,有什么帮助吗?谢谢你
这是我的音频类:
- (id)initWithSoundfileName:(NSString*) file
{
if ((self = [super init]))
{
NSString* filename = [file stringByDeletingPathExtension];
NSString* fileextension = [file pathExtension];
// get file path from bundle
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: filename ofType: fileextension];
NSLog(@"AudioPlayer init: %@", soundFilePath);
NSURL* fileurl = [[NSURL alloc] initFileURLWithPath:soundFilePath];
NSError* error = nil;
AVAudioPlayer* audioplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileurl error:&error ];
if (error) { NSLog(@"Error creating AVAudioPlayer %@", [error description]);}
// set audio policy
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:NULL];
self.player = audioplayer;
[self.player prepareToPlay];
[self.player setDelegate:self];
}
return self;
}
-(void) play{
[self.player play];
}
这是我的视频播放方法:
- (void)playIntroVideo
{
NSString *movpath = [[NSBundle mainBundle] pathForResource:@"mymovie" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:movpath];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
self.moviePlayerController.fullscreen = YES;
self.moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
self.moviePlayerController.controlStyle = MPMovieControlStyleNone;
self.moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
self.moviePlayerController.useApplicationAudioSession = NO;
[self.moviePlayerController.view setFrame: self.view.bounds];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:self.moviePlayerController];
[self.view addSubview:self.moviePlayerController.view];
[self.moviePlayerController prepareToPlay];
[self.moviePlayerController play];
}
最佳答案
就像@Till 提到的:当我将 MoviePlayerController
属性更改为 useApplicationAudioSession=TRUE
时,它解决了我的问题。音频播放静音。
关于ios - 尽管在静音模式下电影的音频播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11528986/
是否有一些系统通知可供我订阅,以便在用户切换响铃/静音按钮时收到通知?我还想知道苹果是否提供了一些“系统通知列表”。我花了一个小时搜索这个但失败了。 最佳答案 没有办法找出这一点。苹果在回应一些请求时
我用 a-videosphere 制作了一个 a-scene。我尝试使用按钮启用/禁用声音,但有些想法不起作用?这是我的代码: var gargamel = 0; function
我正在寻找可以检测并让我知道1分钟的wav文件是否包含声音的实用程序/代码? 换句话说,如果它可以检测到wav文件中任何位置的静默持续时间(如果存在),则也可以达到目的。 SOX是否为此支持任何命令?
我想知道是否可以只使特定 窗口静音。例如,我打开了 Firefox 和另外两个窗口。我想将与 Firefox 相关的所有内容静音,但不想关闭计算机的全部声音。 这可能吗?如果可以,如何实现? 最佳答案
我不知道如何处理我的 JavaScript 中的静音/取消静音按钮,我已经处理这个问题好几个小时了!基本上我的静音按钮可以正常工作,它可以使视频静音,我现在正试图让同一个按钮取消视频静音。有任何想法吗
我正在尝试将 AVCaptureSession 的音频静音和取消静音。开始 session 后,我可以启用和禁用音频连接,但是一旦我播放视频,所有音频部分都会被推回视频的前面,只留下视频的结尾没有声音
我有一组 php/html 页面,其中包含当鼠标悬停在其上时会播放声音的按钮。现在我希望当用户单击另一个按钮时,它会使网站的所有页面静音或将它们置于声音中,具体取决于声音是否已打开。 我已经有一个 h
我正在使用 AudioServicesPlaySystemSoundWithCompletion 播放系统声音,并使用 AVAudioPlayer 播放自定义声音。 为什么打开静音开关会播放声音?我已
我正在使用名为 ExoPlayer 的 Google 新 MediaPlayer,但找不到静音的方法 有没有一种简单的方法可以在 Google ExoPlayer 上将音轨静音?还是改变音量? 最佳答
我收到了大量关于零时长和弦的 music21 警告: WARNING: midi chord with zero duration will be treated as grace 我尝试用以下内容覆
我正在尝试在后台启动端口转发,同时抑制所有输出。这是我尝试过的: kubectl port-forward pod-name 1234:1234 > /dev/null 2>&1 & 然而,当我发起连
我想继续录音,但音频已静音。我是 不是 希望暂停音频。 我现在的替代方法是暂停音频,加入静音填充,继续录音,但如果有更简单的方法,那就太好了。 最佳答案 我也遇到过这个问题,经过长时间的研究,我得到了
在我的 iPhone 应用程序中,我想要静音和取消静音 MPMoviePlayerController。我进行了很多搜索,但无法成功。是否可以在 MPMoviePlayer Controller 中将
我已经看到了确保应用程序遵循静音开关的技术,但是是否可以使用 SDK 将 iPhone 设置为静音(任何应用程序都不会发出声音)? 最佳答案 没有。 使用官方 SDK 开发的应用程序无法更改(并且在大
我要播放以下背景音乐: NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/bgMusic.mp3", [[NSBu
我希望仅为我的 WPF 应用程序静音,并让整个混音器保持用户设置的状态。 我可以使用以下代码使系统范围内的声音静音/取消静音。 但是我注意到当我的应用程序正在运行并且正在播放声音时,我的应用程序会出现
所以我有一个 iframe,其“src”指向一些音乐的 URL。 iframe 被隐藏并自动播放音乐。如何添加一个按钮来使音乐静音? 请注意,音乐来自外部网站。而且 URL 并不指向特定文件。它只是
我正在制作一个小型 Java 应用程序,该应用程序需要以隐藏模式打开 Firefox 浏览器并将其静音。 正如您通过下面的代码看到的,我找到了一种隐藏浏览器的方法。然而,我在弄清楚如何使浏览器静音以及
我正在为我的应用程序使用 SpeechRecognizer API,每次启动时,它都会播放“哔”声。 我想知道如何将它静音,这样我就可以自己实现一个。 谢谢。 最佳答案 如果您使用按钮来激活和停用识别
我正在创建我的第一个应用程序。我有一个使用以下代码在后台播放音乐的应用程序: var backgroundMusicPlayer = AVAudioPlayer() override func vie
我是一名优秀的程序员,十分优秀!