- add audio renderer based on android native renderer (WIP, needs naming cleanup) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11039 75d07b2b-3a1a-0410-a2c5-0572b91ccdcaexperimental
parent
eac0f14cab
commit
9df246324d
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,67 @@ |
|||||||
|
package com.jme3.audio.android; |
||||||
|
|
||||||
|
import com.jme3.asset.AssetKey; |
||||||
|
import com.jme3.audio.AudioData; |
||||||
|
import com.jme3.audio.AudioRenderer; |
||||||
|
import com.jme3.util.NativeObject; |
||||||
|
|
||||||
|
public class AndroidAudioData extends AudioData { |
||||||
|
|
||||||
|
protected AssetKey<?> assetKey; |
||||||
|
protected float currentVolume = 0f; |
||||||
|
|
||||||
|
public AndroidAudioData(){ |
||||||
|
super(); |
||||||
|
} |
||||||
|
|
||||||
|
protected AndroidAudioData(int id){ |
||||||
|
super(id); |
||||||
|
} |
||||||
|
|
||||||
|
public AssetKey<?> getAssetKey() { |
||||||
|
return assetKey; |
||||||
|
} |
||||||
|
|
||||||
|
public void setAssetKey(AssetKey<?> assetKey) { |
||||||
|
this.assetKey = assetKey; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataType getDataType() { |
||||||
|
return DataType.Buffer; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public float getDuration() { |
||||||
|
return 0; // TODO: ???
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void resetObject() { |
||||||
|
this.id = -1; |
||||||
|
setUpdateNeeded(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void deleteObject(Object rendererObject) { |
||||||
|
((AudioRenderer)rendererObject).deleteAudioData(this); |
||||||
|
} |
||||||
|
|
||||||
|
public float getCurrentVolume() { |
||||||
|
return currentVolume; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCurrentVolume(float currentVolume) { |
||||||
|
this.currentVolume = currentVolume; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public NativeObject createDestructableClone() { |
||||||
|
return new AndroidAudioData(id); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public long getUniqueId() { |
||||||
|
return ((long)OBJTYPE_AUDIOBUFFER << 32) | ((long)id); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.jme3.audio.android; |
||||||
|
|
||||||
|
import com.jme3.audio.AudioRenderer; |
||||||
|
|
||||||
|
/** |
||||||
|
* Android specific AudioRenderer interface that supports pausing and resuming |
||||||
|
* audio files when the app is minimized or placed in the background |
||||||
|
* |
||||||
|
* @author iwgeric |
||||||
|
*/ |
||||||
|
public interface AndroidAudioRenderer extends AudioRenderer { |
||||||
|
|
||||||
|
/** |
||||||
|
* Pauses all Playing audio. To be used when the app is placed in the |
||||||
|
* background. |
||||||
|
*/ |
||||||
|
public void pauseAll(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Resumes all Paused audio. To be used when the app is brought back to |
||||||
|
* the foreground. |
||||||
|
*/ |
||||||
|
public void resumeAll(); |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@ |
|||||||
|
package com.jme3.audio.plugins; |
||||||
|
|
||||||
|
import com.jme3.asset.AssetInfo; |
||||||
|
import com.jme3.asset.AssetLoader; |
||||||
|
import com.jme3.audio.android.AndroidAudioData; |
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
/** |
||||||
|
* <code>AndroidAudioLoader</code> will create an |
||||||
|
* {@link AndroidAudioData} object with the specified asset key. |
||||||
|
*/ |
||||||
|
public class AndroidAudioLoader implements AssetLoader { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object load(AssetInfo assetInfo) throws IOException { |
||||||
|
AndroidAudioData result = new AndroidAudioData(); |
||||||
|
result.setAssetKey(assetInfo.getKey()); |
||||||
|
return result; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue