Unity3D-在Android上收到任何呼叫/通知后,音频播放会静音 [英] Unity3D - Audio playing getting muted after getting any call/notification on Android

查看:425
本文介绍了Unity3D-在Android上收到任何呼叫/通知后,音频播放会静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android版本上遇到音频播放问题.我正在使用Unity 5.4.0b15,但在5.3.4p3上也遇到了同样的问题.

I have audio playing issue on Android build. I'm using Unity 5.4.0b15, but I had same issue on 5.3.4p3.

我的场景中添加了用于播放背景音乐的简单组件,该组件已添加到"AudioPlayer" GameObject中.

I have simple component for playing background music added to "AudioPlayer" GameObject in my scene.

public AudioClip clip;
private AudioSource _musicAudioSource;

private void Awake()
{
   if (_musicAudioSource == null)
   {
       _musicAudioSource = gameObject.AddComponent<AudioSource>();
   }
   _musicAudioSource.loop = true;
   _musicAudioSource.clip = clip;
   _musicAudioSource.Play();
}

在Android设备上运行游戏后,音乐开始完美播放.但是当它运行时,我收到任何形式的通知或呼叫(电话,viber或任何其他Massinger),音乐将停止播放.另外,我在游戏中使用的所有其他声音也会变得静音.重新开始播放音频的唯一方法是杀死应用程序并再次运行.

After running game on Android devices the music starts playing perfectly. But while it running I'm getting any kind of notification or call (phone, viber or any other massinger) the music stops playing. Also all the other sounds playing getting muted, which I used in gameplay. The only way to restart playing audio is to kill application and run it again.

当我在运行游戏时使用本机播放器(如播放音乐")收听任何音频时,也会遇到同样的静音问题.

Also getting same muted issue, when I'm running game while listening any audio using native player, like Play Music.

在iOS上,一切正常.

On iOS everything works perfectly.

推荐答案

这绝对是Unity中的错误.我遇到了同样的问题,并进行了一些测试以尝试解决该问题,但是如果不重新启动应用程序,就无法恢复音频.

This is definitely a bug in Unity. I bumped into the same problem and ran some tests to try to fix it but there is no way to recover the audio without restarting the app.

在测试中,我使用Google环聊通知杀死了音频.

In my tests I used Google Hangouts notifications to kill the audio.

程序员建议的修复程序将不起作用,原因是: 1.该通知不会触发应用程序暂停或应用程序焦点事件. 2.初始化新的AudioListener和/或AudioSource实例也不会恢复音频.

Programmer's proposed fix won't work because: 1. The notification does not trigger application pause nor application focus events. 2. Initializing a new AudioListener and/or AudioSource instances will not recover the audio either.

这是Unity中的低级错误.我将报告该错误.

This is a low level bug in Unity. I will make a report on the bug.

这篇关于Unity3D-在Android上收到任何呼叫/通知后,音频播放会静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆