001: /*
002: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License version
007: * 2 only, as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful, but
010: * WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * General Public License version 2 for more details (a copy is
013: * included at /legal/license.txt).
014: *
015: * You should have received a copy of the GNU General Public License
016: * version 2 along with this work; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018: * 02110-1301 USA
019: *
020: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021: * Clara, CA 95054 or visit www.sun.com if you need additional
022: * information or have any questions.
023: */
024: package com.sun.mmedia;
025:
026: import javax.microedition.media.*;
027: import javax.microedition.media.control.VolumeControl;
028:
029: /**
030: * Description of the Class
031: *
032: * @created January 17, 2005
033: */
034: public abstract class AudioRenderer implements VolumeControl {
035: /**
036: * Description of the Field
037: */
038: protected boolean muted;
039:
040: /**
041: * Description of the Field
042: */
043: protected int level;
044:
045: private BasicPlayer player;
046:
047: /**
048: * Description of the Method
049: *
050: * @param player Description of the Parameter
051: */
052: public void init(BasicPlayer player) {
053: this .player = player;
054: }
055:
056: /**
057: * Sets the mute attribute of the AudioRenderer object
058: *
059: * @param mute The new mute value
060: */
061: public void setMute(boolean mute) {
062: if (mute && !muted) {
063: player.doSetLevel(0);
064: muted = true;
065: player.sendEvent(PlayerListener.VOLUME_CHANGED, this );
066: } else if (!mute && muted) {
067: level = player.doSetLevel(level);
068: muted = false;
069: player.sendEvent(PlayerListener.VOLUME_CHANGED, this );
070: }
071: }
072:
073: /**
074: * Gets the muted attribute of the AudioRenderer object
075: *
076: * @return The muted value
077: */
078: public boolean isMuted() {
079: return muted;
080: }
081:
082: /**
083: * Sets the level attribute of the AudioRenderer object
084: *
085: * @param ll The new level value
086: * @return Description of the Return Value
087: */
088: public int setLevel(int ll) {
089: int newl;
090:
091: if (ll < 0) {
092: ll = 0;
093: } else if (ll > 100) {
094: ll = 100;
095: }
096:
097: if (!muted) {
098: newl = player.doSetLevel(ll);
099: if (newl != level) {
100: level = newl;
101: player.sendEvent(PlayerListener.VOLUME_CHANGED, this );
102: }
103: }
104:
105: return level;
106: }
107:
108: /**
109: * Gets the level attribute of the AudioRenderer object
110: *
111: * @return The level value
112: */
113: public int getLevel() {
114: return level;
115: }
116: }
|