游戏是否应要求在Android上使用Audio Focus? [英] Should Games request Audio Focus on Android?

查看:66
本文介绍了游戏是否应要求在Android上使用Audio Focus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直阅读关于"Audio Focus"的Android文档,以及他们提出的最佳做法,但有一件事暗示着我...

I have been reading the Android documentation on "Audio Focus", and the best-practices they lay out, but one thing alludes me...

游戏几乎一直都需要音乐,因此请求Audio Focus OnStart 很有意义,但这会导致不良的用户体验.

Games need music pretty much the whole time, so it makes sense to request Audio Focus OnStart, but this can lead to a bad user experience.

如果我的应用程序请求Audio Focus,并且当前正在播放音乐(例如Samsung Music Player),则我的请求将强制停止其音乐.我知道的唯一特殊情况是,当用户在通话中时是否请求音频焦点".

If my App requests Audio Focus, and something is currently playing music already (eg. Samsung Music Player), my request will forcefully stop their music. The only special case I know of is if you request Audio Focus while the user is in a Phone Conversation.

我认为用户期望会发生什么,如果他们还没有在听音乐(或播客等),则应该玩游戏音乐.但是,如果他们已经在听自己的音乐,则该游戏不应播放音乐(但仍可以播放声音效果).

I think what the user expects to happen, is if they are not already listening to music (or podcast, or whatever), then the game music should play. However, if they are already listening to their own music, then the game should not play music (but still play sound effects).

这是Xbox,Windows Phone,PS3等上的工作方式.

This is how things work on Xbox, Windows Phone, PS3, etc.

这就是Android上的样子吗?有没有人想出一个不错的解决方案?

Is this just how it is on Android? Has anyone come up with a nice work around?

注意:我熟悉 AudioManager.IOnAudioFocusChangeListener .我是在专门谈论有关Audio Focus的最初要求.

Note: I am familiar with AudioManager.IOnAudioFocusChangeListener. I am speaking specifically about the initial request for Audio Focus.

推荐答案

在请求音频焦点时避免停止播放某些其他特殊情况是允许其回避,但这适用于瞬态损耗,这不是您所需要的会做的.无法知道另一个应用程序是否正在播放音频,因此您将要么获取音频并杀死音乐,要么无法请求音频并希望获得最佳效果.

The other special case to avoid stopping something from playing when requesting audio focus is to allow it to duck, but that applies to transient loss which isn't what you would be doing. There's no way to know if another app is playing audio unfortunately so you will either take the audio and kill the music or you can not request the audio and hope for the best.

如果用户正在听自己的音乐,可能值得在启动时提示用户,如果这样,那么您的游戏音乐将保持沉默.

It might be worth prompting the user on launch if they are listening to their own music and if so then your game music will remain silent.

这篇关于游戏是否应要求在Android上使用Audio Focus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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