Wings-of-Glory
28-12-2002, 16:59
tja, hab mal versprochen, dass ich das programm poste, dass so halbwegs funktioniert.
nur die stop funktion funktioniert noch nicht.
vielleicht bekommt das auch noch wer hin.
/*
* SimpleAudioPlayer.java
*
* Created on 24. November 2002, 09:37
*/
//PROGRAMMAUFRUF java SimpleAudioPlayer <PFAD ZUR DATEI, kein leerzeichen erlaubt>
//package jmfbasics;
import javax.media.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
public class SimpleAudioPlayer {
private Player audioPlayer = null;
/** Creates a new instance of SimpleAudioPlayer */
public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException, CannotRealizeException {
audioPlayer = Manager.createRealizedPlayer(url);
}
public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, CannotRealizeException {
this(file.toURL());
}
public void play() {
if (audioPlayer!=null) {
audioPlayer.start();
}
}
public void stop() {
if (audioPlayer!=null) {
audioPlayer.stop();
audioPlayer.deallocate();
}
}
public static void main(String[] args) {
File audioFile = new File(args[0]);
try {
SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile);
player.play();
//player.stop();
}
catch (Exception e) {
}
// player.stop();
}
}
nur die stop funktion funktioniert noch nicht.
vielleicht bekommt das auch noch wer hin.
/*
* SimpleAudioPlayer.java
*
* Created on 24. November 2002, 09:37
*/
//PROGRAMMAUFRUF java SimpleAudioPlayer <PFAD ZUR DATEI, kein leerzeichen erlaubt>
//package jmfbasics;
import javax.media.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
public class SimpleAudioPlayer {
private Player audioPlayer = null;
/** Creates a new instance of SimpleAudioPlayer */
public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException, CannotRealizeException {
audioPlayer = Manager.createRealizedPlayer(url);
}
public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, CannotRealizeException {
this(file.toURL());
}
public void play() {
if (audioPlayer!=null) {
audioPlayer.start();
}
}
public void stop() {
if (audioPlayer!=null) {
audioPlayer.stop();
audioPlayer.deallocate();
}
}
public static void main(String[] args) {
File audioFile = new File(args[0]);
try {
SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile);
player.play();
//player.stop();
}
catch (Exception e) {
}
// player.stop();
}
}