获得媒体播放器先玩上右扬声器,然后在左扬声器 [英] Get media player to play first on right speaker and then on left speaker

查看:195
本文介绍了获得媒体播放器先玩上右扬声器,然后在左扬声器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想播放开始于左扬声器,然后切换到右侧扬声器的音频文件。

I would like to play an audio file that starts on the left speaker and then switches to the right speaker.

我曾尝试做这样的事情:

I have tried doing something like this:

MediaPlayer mp = new MediaPlayer();

// Setup audio file

mp.start(); 

mp.setVolume(1.0F, 0F);

// Delay a second or two (I actually use a Handler and the postDelayed method)

mp.setVolume(0F, 1.0F);

但声音是通过两个扬声器的全部时间。

but the sound comes through on both speakers the whole time.

我如何能在Android中播放音频与左或右扬声器静音(或降低音量)?

How can I play audio in Android with either the left or right speaker muted (or at reduced volume)?

修改

我得到了一会儿正确的行为,而我在测试我的应用程序,但随后回到了完全相同的code碱基上述我。在此基础上,还有什么我可以检查以找出发生了什么事情?

I got the correct behavior for a while while I was testing my app, but then it returned to what I described above with the exact same code base. Based on this, is there anything else I could check to find out what's going on?

推荐答案

一种选择是


  1. 先从setVolume(1.0F,0F)媒体播放器;

  2. 当你想切换到其他的扬声器,通过使用getCurrentPosition()方法来获取媒体播放器的当前位置。

  3. 然后停止媒体播放器。

  4. 然后再以setVolume(0F,1.0F)启动;

  5. 寻到positin您在第2步使用了seekTo()方法

完成。

开销:这种方法可能会导致你一些延迟

Overhead:This method may cause you some delay

这篇关于获得媒体播放器先玩上右扬声器,然后在左扬声器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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