当前位置: 首页>>代码示例>>Java>>正文


Java AudioKey类代码示例

本文整理汇总了Java中com.jme3.audio.AudioKey的典型用法代码示例。如果您正苦于以下问题:Java AudioKey类的具体用法?Java AudioKey怎么用?Java AudioKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioKey类属于com.jme3.audio包,在下文中一共展示了AudioKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processOpen

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * Open this audio data in the audio viewer.
 */
@FXThread
protected void processOpen() {

    final AudioKey element = getPropertyValue();
    if (element == null) return;

    final String assetPath = element.getName();
    if (StringUtils.isEmpty(assetPath)) return;

    final Path assetFile = Paths.get(assetPath);
    final Path realFile = notNull(getRealFile(assetFile));
    if (!Files.exists(realFile)) return;

    final RequestedOpenFileEvent event = new RequestedOpenFileEvent();
    event.setFile(realFile);

    FX_EVENT_MANAGER.notify(event);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:AudioKeyPropertyControl.java

示例2: process

import com.jme3.audio.AudioKey; //导入依赖的package包/类
@Override
@FXThread
protected void process() {
    super.process();

    final AudioTreeNode audioModelNode = (AudioTreeNode) getNode();
    final AudioNode audioNode = audioModelNode.getElement();

    final AssetManager assetManager = EDITOR.getAssetManager();

    EXECUTOR_MANAGER.addJMETask(() -> {

        final AudioKey audioKey = AudioNodeUtils.getAudioKey(audioNode);
        final AudioData audioData = assetManager.loadAudio(audioKey);

        AudioNodeUtils.updateData(audioNode, audioData, audioKey);

        audioNode.play();
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:PlayAudioNodeAction.java

示例3: load

import com.jme3.audio.AudioKey; //导入依赖的package包/类
public Object load(AssetInfo info) throws IOException {
    if (!(info.getKey() instanceof AudioKey)){
        throw new IllegalArgumentException("Audio assets must be loaded using an AudioKey");
    }
    
    AudioKey key = (AudioKey) info.getKey();
    boolean readStream = key.isStream();
    boolean streamCache = key.useStreamCache();
    
    InputStream in = null;
    try {
        in = info.openStream();
        AudioData data = load(in, readStream, streamCache);
        if (data instanceof AudioStream){
            // audio streams must remain open
            in = null;
        }
        return data;
    } finally {
        if (in != null){
            in.close();
        }
    }
    
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:OGGLoader.java

示例4: load

import com.jme3.audio.AudioKey; //导入依赖的package包/类
public Object load(AssetInfo info) throws IOException {
    AudioData data;
    InputStream inputStream = null;
    try {
        inputStream = info.openStream();
        data = load(inputStream, ((AudioKey)info.getKey()).isStream());
        if (data instanceof AudioStream){
            inputStream = null;
        }
        return data;
    } finally {
        if (inputStream != null){
            inputStream.close();
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:WAVLoader.java

示例5: loadImpl

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * Load the audio data.
 *
 * @param audioData the audio data.
 * @param audioKey  the audio key.
 */
@JMEThread
private void loadImpl(@NotNull final AudioData audioData, @NotNull final AudioKey audioKey) {
    removeAudioNode();
    setAudioData(audioData);
    setAudioKey(audioKey);

    final Node stateNode = getStateNode();

    final AudioNode audioNode = new AudioNode(audioData, audioKey);
    audioNode.setPositional(false);
    stateNode.attachChild(audioNode);

    setAudioNode(audioNode);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AudioViewer3DState.java

示例6: AudioKeyPropertyControl

import com.jme3.audio.AudioKey; //导入依赖的package包/类
public AudioKeyPropertyControl(@Nullable final AudioKey element, @NotNull final String paramName,
                               @NotNull final C changeConsumer) {
    super(element, paramName, changeConsumer);
    setOnDragOver(this::handleDragOverEvent);
    setOnDragDropped(this::handleDragDroppedEvent);
    setOnDragExited(this::handleDragExitedEvent);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioKeyPropertyControl.java

示例7: addAudioData

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * Add the new audio data.
 *
 * @param file the audio file.
 */
@FXThread
private void addAudioData(@NotNull final Path file) {

    final Path assetFile = notNull(getAssetFile(file));
    final AudioKey audioKey = new AudioKey(toAssetPath(assetFile));

    changed(audioKey, getPropertyValue());
    setIgnoreListener(true);
    try {
        reload();
    } finally {
        setIgnoreListener(false);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:20,代码来源:AudioKeyPropertyControl.java

示例8: reload

import com.jme3.audio.AudioKey; //导入依赖的package包/类
@Override
@FXThread
protected void reload() {
    final AudioKey element = getPropertyValue();
    final Label audioKeyLabel = getAudioKeyLabel();
    audioKeyLabel.setText(element == null || StringUtils.isEmpty(element.getName()) ? NO_AUDIO : element.getName());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioKeyPropertyControl.java

示例9: openFile

import com.jme3.audio.AudioKey; //导入依赖的package包/类
@Override
@FXThread
public void openFile(@NotNull final Path file) {
    super.openFile(file);

    final Path assetFile = notNull(EditorUtil.getAssetFile(file));
    final String assetPath = EditorUtil.toAssetPath(assetFile);

    final AudioKey audioKey = new AudioKey(assetPath);
    final AssetManager assetManager = EDITOR.getAssetManager();
    final AudioData audioData = assetManager.loadAudio(audioKey);

    final float duration = audioData.getDuration();
    final int bitsPerSample = audioData.getBitsPerSample();
    final int channels = audioData.getChannels();
    final AudioData.DataType dataType = audioData.getDataType();
    final int sampleRate = audioData.getSampleRate();

    final AudioViewer3DState editorAppState = getEditorAppState();
    editorAppState.load(audioData, audioKey);

    getChannelsField().setText(String.valueOf(channels));
    getDurationField().setText(String.valueOf(duration));
    getDataTypeField().setText(String.valueOf(dataType));
    getSampleRateField().setText(String.valueOf(sampleRate));
    getBitsPerSampleField().setText(String.valueOf(bitsPerSample));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:AudioViewerEditor.java

示例10: updateData

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * Update audio data for an audio node.
 *
 * @param audioNode the audio node.
 * @param audioData the audio data.
 * @param audioKey  the audio key.
 */
@JMEThread
public static void updateData(@NotNull final AudioNode audioNode, @Nullable final AudioData audioData,
                              @Nullable final AudioKey audioKey) {
    try {
        AUDIO_DATA_FIELD.set(audioNode, audioData);
        AUDIO_KEY_FIELD.set(audioNode, audioKey);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:AudioNodeUtils.java

示例11: getAudioKey

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * Get an audio key from the audio node.
 *
 * @param audioNode the audio node.
 * @return the audio key.
 */
@Nullable
@FromAnyThread
public static AudioKey getAudioKey(@NotNull final AudioNode audioNode) {
    try {
        return (AudioKey) AUDIO_KEY_FIELD.get(audioNode);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:16,代码来源:AudioNodeUtils.java

示例12: load

import com.jme3.audio.AudioKey; //导入依赖的package包/类
public Object load(AssetInfo info) throws IOException {
	InputStream in=info.openStream();
	try{
		
		FlacAudioFileReader audio_file_reader=new FlacAudioFileReader();
		AudioInputStream audio_input_stream=audio_file_reader.getAudioInputStream(in);

		
		AudioFormat sourceFormat=audio_input_stream.getFormat();
		AudioFormat targetFormat = new AudioFormat(
						AudioFormat.Encoding.PCM_SIGNED,
						(int)(sourceFormat.getSampleRate()), 
						sourceFormat.getSampleSizeInBits(), 
						sourceFormat.getChannels(),
						sourceFormat.getChannels() * (sourceFormat.getSampleSizeInBits() / 8), 
						(int)(sourceFormat.getSampleRate()), 
						sourceFormat.isBigEndian());
		FlacFormatConversionProvider flacCoverter = new FlacFormatConversionProvider();
		audio_input_stream = flacCoverter.getAudioInputStream(targetFormat, audio_input_stream);

		
		
        return ((AudioKey)info.getKey()).isStream()
        	?toJMEAudioStream(audio_input_stream)
        	:toJMEAudioBuffer(audio_input_stream);

	}catch(Exception e){
		e.printStackTrace();
	}finally{
		in.close();
	}
	return null;
}
 
开发者ID:riccardobl,项目名称:jme3-plugin-flac-loader,代码行数:34,代码来源:FLACLoader.java

示例13: deleteAudioData

import com.jme3.audio.AudioKey; //导入依赖的package包/类
@Override
public void deleteAudioData(AudioData ad) {
    if (ad instanceof AndroidAudioData) {
        AndroidAudioData audioData = (AndroidAudioData) ad;
        if (audioData.getAssetKey() instanceof AudioKey) {
            AudioKey assetKey = (AudioKey) audioData.getAssetKey();
            if (assetKey.isStream()) {
                for (AudioNode src : musicPlaying.keySet()) {
                    if (src.getAudioData() == ad) {
                        MediaPlayer mp = musicPlaying.get(src);
                        mp.stop();
                        mp.release();
                        musicPlaying.remove(src);
                        src.setStatus(Status.Stopped);
                        src.setChannel(-1);
                        break;
                    }
                }
            } else {
                if (audioData.getId() > 0) {
                    soundPool.unload(audioData.getId());
                }
                audioData.setId(0);
            }

        }
    } else {
        throw new IllegalArgumentException("AudioData is not of type AndroidAudioData in deleteAudioData");
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:31,代码来源:AndroidAudioRenderer.java

示例14: getAudioKey

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * @return the audio key.
 */
@JMEThread
private @NotNull AudioKey getAudioKey() {
    return notNull(audioKey);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioViewer3DState.java

示例15: setAudioKey

import com.jme3.audio.AudioKey; //导入依赖的package包/类
/**
 * @param audioKey the audio key.
 */
@JMEThread
private void setAudioKey(@NotNull final AudioKey audioKey) {
    this.audioKey = audioKey;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioViewer3DState.java


注:本文中的com.jme3.audio.AudioKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。