本文介绍了MediaControllerCompat-java.lang.IllegalArgumentException:错误的方向3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我的mediaControllerCompat发布一个简单的命令:

I'm issuing a simple command to my mediaControllerCompat:

controller.adjustVolume(-1,0);

controller.adjustVolume(-1, 0);

但我的应用FC具有...

Yet my app FCs with...

java.lang.IllegalArgumentException: Bad direction 3
       at android.os.Parcel.readException(Parcel.java:1469)
       at android.os.Parcel.readException(Parcel.java:1419)
       at android.media.IAudioService$Stub$Proxy.adjustStreamVolume(IAudioService.java:1097)
       at android.media.AudioManager.adjustStreamVolume(AudioManager.java:952)
       at android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase.adjustVolume(MediaSessionCompat.java:1376)
       at android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase.access$1700(MediaSessionCompat.java:963)
       at android.support.v4.media.session.MediaSessionCompat$MediaSessionImplBase$MediaSessionStub.adjustVolume(MediaSessionCompat.java:1602)
       at android.support.v4.media.session.MediaControllerCompat$MediaControllerImplBase.adjustVolume(MediaControllerCompat.java:969)
       at android.support.v4.media.session.MediaControllerCompat.adjustVolume(MediaControllerCompat.java:252)
       at pl.qus.xenoamp.NewMainActivity.onKeyDown(NewMainActivity.java:1149)

MainActivity是提到的行的调用者……什么是错?!

MainActivity being the caller of mentioned line... What is WRONG?!

推荐答案

这是Android支持库中的一个内部错误,自版本23.1.0起已得到修复.

This was an internal bug in the Android Support Library has been fixed as of version 23.1.0.

上一个答案

这是支持库中的一个错误,该错误会影响使用本地播放的API 21之前的设备(即尚未调用 setPlaybackToRemote())-发送给 AudioManager.adjustStreamVolume()按照源代码不正确-因此,为什么方向显示为3- STREAM_MUSIC .

This is a bug in the support library that affects pre-API 21 devices that use local playback (i.e., have not called setPlaybackToRemote()) - the order of parameters sent to AudioManager.adjustStreamVolume() as per the source code is incorrect - hence why the direction appearing as 3 - the value for STREAM_MUSIC.

通过始终调用 setPlaybackToRemote(),并传入 VolumeProviderCompat 正确地调用 AudioManager.adjustStreamVolume(),但您还必须处理VolumeProviderCompat的其他方法,例如检索最大音量(通过 getStreamMaxVolume())和当前音量(通过 getStreamVolume())以及设置音量(通过 setStreamVolume()).

You may be able to temporarily work around it by always calling setPlaybackToRemote() on pre-API 21 devices, passing in a VolumeProviderCompat that does correctly call AudioManager.adjustStreamVolume(), but you must also handle the other methods of VolumeProviderCompat such as retrieving the max volume (via getStreamMaxVolume()) and current volume (via getStreamVolume()) as well as setting the volume (via setStreamVolume()).

这篇关于MediaControllerCompat-java.lang.IllegalArgumentException:错误的方向3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:55