DirectVolumepublic class DirectVolume extends Object implements VolumeControlNative volume control implementation |
Fields Summary |
---|
private int | _level | private int | _mute | private int | _hNative | private BasicPlayer | _player |
Constructors Summary |
---|
DirectVolume(BasicPlayer player, int hNative)
_player = player;
_hNative = hNative;
|
Methods Summary |
---|
public int | getLevel()
if (_level == -1) {
_level = nGetVolume(_hNative);
}
return _level;
| public boolean | isMuted()
if (_mute != -1) return (_mute == 1);
if (true == nIsMuted(_hNative)) {
_mute = 1;
return true;
} else {
_mute = 0;
return false;
}
| protected native int | nGetVolume(int hNative)
| protected native boolean | nIsMuted(int hNative)
| protected native boolean | nSetMute(int hNative, boolean mute)
| protected native int | nSetVolume(int hNative, int level)
| public int | setLevel(int level)
if (level < 0) {
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_MMAPI,
"volume level " + level + " is negative, change to 0");
}
level = 0;
} else if (level > 100) {
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_MMAPI,
"volume level " + level + " is too big, change to 100");
}
level = 100;
}
// Volume value is same. just return.
if (_level == level) {
return _level;
}
// If this player is not started yet, this new volume will be setted
// when this player start
if (_player.state == Player.STARTED) {
if (-1 == nSetVolume(_hNative, level)) {
if (Logging.REPORT_LEVEL <= Logging.ERROR) {
Logging.report(Logging.ERROR, LogChannels.LC_MMAPI,
"set volume failed volume=" + _level);
}
}
}
_level = level;
_player.sendEvent(PlayerListener.VOLUME_CHANGED, this);
return _level;
| public void | setMute(boolean mute)
if (_player.state == Player.STARTED) {
nSetMute(_hNative, mute);
}
_mute = mute ? 1 : 0;
| void | setToPlayerMute()
if (_mute == -1) return;
nSetMute(_hNative, _mute == 1);
| void | setToThisPlayerLevel()
if (_level == -1) return;
nSetVolume(_hNative, _level);
|
|