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


Java Type类代码示例

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


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

示例1: playClip

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public static void playClip(File clipFile) throws IOException, 
  UnsupportedAudioFileException, LineUnavailableException, InterruptedException {
  class AudioListener implements LineListener {
    private boolean done = false;
    @Override public synchronized void update(LineEvent event) {
      Type eventType = event.getType();
      if (eventType == Type.STOP || eventType == Type.CLOSE) {
        done = true;
        notifyAll();
      }
    }
    public synchronized void waitUntilDone() throws InterruptedException {
      while (!done) { wait(); }
    }
  }
  AudioListener listener = new AudioListener();
  AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(clipFile);
  try {
    Clip clip = AudioSystem.getClip();
    clip.addLineListener(listener);
    clip.open(audioInputStream);
    try {
      clip.start();
      listener.waitUntilDone();
    } finally {
      clip.close();
    }
  } finally {
    audioInputStream.close();
  }
}
 
开发者ID:Jahani,项目名称:EnchantedForest,代码行数:32,代码来源:Sound.java

示例2: VentanaInternaGrabador

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public VentanaInternaGrabador(final File f) {
    initComponents();

    recorder = new SMSoundPlayerRecorder(f);
    this.setTitle(f.getName());
    LineListener lineListener = new LineListener() {
        @Override
        public void update(LineEvent event) {
            if (event.getType() == Type.START) {
                recorderButton.setEnabled(false);
                stopButton.setEnabled(true);
            }
            if (event.getType() == Type.STOP) {
                recorderButton.setEnabled(true);
                stopButton.setEnabled(false);
                VentanaInternaReproductor vir = new VentanaInternaReproductor(f);
                VentanaPrincipal.getEscritorio().add(vir);
                vir.setVisible(true);
            }

        }
    };
    ((SMSoundPlayerRecorder) recorder).setLineListener(lineListener);
    this.pack();
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:26,代码来源:VentanaInternaGrabador.java

示例3: VentanaInternaReproductor

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public VentanaInternaReproductor(File f) {
    initComponents();

    player = new SMSoundPlayerRecorder(f);
    this.setTitle(f.getName());
    LineListener lineListener = new LineListener() {
        @Override
        public void update(LineEvent event) {
            if (event.getType() == Type.START) {
                play.setEnabled(false);
                stop.setEnabled(true);
            }
            if (event.getType() == Type.STOP) {
                play.setEnabled(true);
                play.setSelected(false);
                stop.setEnabled(false);
            }
        }
    };
    ((SMSoundPlayerRecorder)player).setLineListener(lineListener);
    this.pack();
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:23,代码来源:VentanaInternaReproductor.java

示例4: VentanaInternaGrabador

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public VentanaInternaGrabador() {
    initComponents();
    exist=true;
    recorder = new SMSoundPlayerRecorder(new File("nuevo"));
    LineListener lineListener = new LineListener() {
        @Override
        public void update(LineEvent event) {
            if (event.getType() == Type.START) {
                recorderButton.setEnabled(false);
                stopButton.setEnabled(true);
            }
            if (event.getType() == Type.STOP) {
                recorderButton.setEnabled(true);
                stopButton.setEnabled(false);
            }

        }
    };
    ((SMSoundPlayerRecorder) recorder).setLineListener(lineListener);
    this.pack();
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:22,代码来源:VentanaInternaGrabador.java

示例5: VentanaInternaReproductor

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public VentanaInternaReproductor(File f) {
    initComponents();
    if (f != null) {
        player = new SMSoundPlayer(f);
        this.setTitle(f.getName());
        LineListener lineListener = new LineListener() {
            @Override
            public void update(LineEvent event) {
                if (event.getType() == Type.START) {
                    play.setEnabled(false);
                    stop.setEnabled(true);
                }
                if (event.getType() == Type.STOP) {
                    play.setEnabled(true);
                    play.setSelected(false);
                    stop.setEnabled(false);
                }
            }
        };
        ((SMSoundPlayer) player).setLineListener(lineListener);
        this.pack();
    }
}
 
开发者ID:oskyar,项目名称:Sistemas-Multimedia,代码行数:24,代码来源:VentanaInternaReproductor.java

示例6: setSoundVolume

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
/**
 * 
 * Automatically called on construction and game setting change to match clip volume to
 * user defined levels.
 * 
 * @param value
 * 		percentage to set music volume to
 * 
 */
private void setSoundVolume(int value) {
	if (value == 0) {
		soundOff = true;
		return;
	}
	
	soundOff = false;
	
	float decibelLevelOffset = SoundUtils.resolveDecibelOffsetFromPercentage(value);
	System.out.println("Decibel offset for sound: " + decibelLevelOffset);
	for (GameSoundEffect effect : GameSoundEffect.values() ) {
		Optional<Clip> clip = sounds.get(effect);
		if (clip.isPresent() ) {
			FloatControl gainControl = (FloatControl)
				clip.get().getControl(FloatControl.Type.MASTER_GAIN);
			gainControl.setValue(decibelLevelOffset);
		}
	}
}
 
开发者ID:ErikaRedmark,项目名称:monkey-shines-java-port,代码行数:29,代码来源:JavaDefaultSoundManager.java

示例7: JSAudio

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
JSAudio(AudioInputStream as) throws LineUnavailableException, IOException {
    Mixer mix = AudioIO.findMixer(as.getFormat());
    clip = (Clip) (mix != null ? mix.getLine(new Line.Info(Clip.class)) : AudioSystem.getLine(new Line.Info(Clip.class)));
    clip.open(as);
    clip.addLineListener(new LineListener() {
        public void update(LineEvent event) {
            if (loop && event.getType() == Type.STOP) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        clip.start();
                    }
                });
            }
        }
    });
}
 
开发者ID:IvyBits,项目名称:Amber-IDE,代码行数:17,代码来源:JSAudio.java

示例8: update

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
/**
 * This method allows to be notified for each event while playing a
 * sound
 */
@Override
public synchronized void update(final LineEvent event) {
	final Type eventType = event.getType();
	if (eventType == Type.STOP || eventType == Type.CLOSE) {
		done = true;
		notifyAll();
	}
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:13,代码来源:TelegraphSound.java

示例9: update

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
/**
 * This method allows to be notified for each event while playing a
 * sound
 */
@Override
public synchronized void update(LineEvent event) {
	Type eventType = event.getType();
	if (eventType == Type.STOP || eventType == Type.CLOSE) {
		done = true;
		notifyAll();
	}
}
 
开发者ID:thahn0720,项目名称:agui_framework,代码行数:13,代码来源:AchievementSound.java

示例10: update

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
@Override
public void update(LineEvent event) {
	if (event.getType().equals(Type.STOP)) {
		// Stop must be called in a separate thread in order for the
		// underflow callback to complete and not deadlock.
		executor.execute(new Runnable() {
			@Override
			public void run() {
				clip.stop();
			}
		});
	}
}
 
开发者ID:itdelatrisu,项目名称:opsu,代码行数:14,代码来源:PulseAudioFixerListener.java

示例11: interrupt

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
@Override
public void interrupt() {
    if (this.line != null && this.line.isOpen() && this.listener != null)
        this.listener.update(
                new LineEvent(this.line, Type.STOP, AudioSystem.NOT_SPECIFIED)
        );
    super.interrupt();
}
 
开发者ID:pleonex,项目名称:UniversityCP,代码行数:9,代码来源:Audio.java

示例12: update

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
@Override
public synchronized void update(LineEvent event) {
    Type eventType = event.getType();
    if (eventType == Type.STOP || eventType == Type.CLOSE) {
        done = true;
        notifyAll();
    }
}
 
开发者ID:pleonex,项目名称:UniversityCP,代码行数:9,代码来源:Audio.java

示例13: playOnceDelayed

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
@Override public void playOnceDelayed(
		final GameSoundEffect effect, 
		final int delay, 
		final TimeUnit unit) {
	
	if (soundOff)  return;
	
	holdSound(effect);
	
	delaySound.schedule(
		new Runnable() { 
			@Override public void run() { 
				playOnce(effect);
				// Block this scheduled thread until sound is over
				Optional<Clip> clip = sounds.get(effect);
				if (clip.isPresent() ) {
					clip.get().addLineListener(new LineListener() {
						@Override public void update(LineEvent event) {
							if (event.getType() == Type.STOP) {
								releaseSound(effect);
							}
						}
					});
				}
			} 
		}, 
		delay,
		unit
	);
}
 
开发者ID:ErikaRedmark,项目名称:monkey-shines-java-port,代码行数:31,代码来源:JavaDefaultSoundManager.java

示例14: setMusicVolume

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
/**
 * Automatically called on construction and game setting change to match clip volume to
 * user defined levels. Does nothing if there is no background music
 * 
 * @param value
 * 		percentage to set music volume to
 */
private void setMusicVolume(int value) {
	if (bgm.isPresent() ) {
		Clip mus = bgm.get();
		if (value == 0) {
			musicOff = true;
			// unlike sounds, music must manually be shut off, and then back on again if required.
			if (mus.isRunning() ) {
				musicCut = true;
				mus.stop();
			}
			return;
		} else {
			// if the music was previously cut because it was already running, then and only then do
			// we resume it.
			if (musicCut) {
				musicCut = false;
				mus.start();
			}
		}

		if (bgm.isPresent() ) {
			musicOff = false;
			FloatControl gainControl = (FloatControl) bgm.get().getControl(FloatControl.Type.MASTER_GAIN);
			float decibelLevelOffset = SoundUtils.resolveDecibelOffsetFromPercentage(value);
			// Music seems to be naturally louder than sound effects, so give it a negative nudge.
			decibelLevelOffset -= 10;
			System.out.println("Decibel offset for music: " + decibelLevelOffset);
			gainControl.setValue(decibelLevelOffset);
		} else {
			musicOff = true;
		}
	}
}
 
开发者ID:ErikaRedmark,项目名称:monkey-shines-java-port,代码行数:41,代码来源:JavaDefaultSoundManager.java

示例15: setVolume

import javax.sound.sampled.LineEvent.Type; //导入依赖的package包/类
public void setVolume(float volume) {
    ((FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN)).setValue(volume);
}
 
开发者ID:IvyBits,项目名称:Amber-IDE,代码行数:4,代码来源:JSAudio.java


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