package com.bird.jmf;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.Manager;
import javax.media.Player;
@SuppressWarnings("restriction")
public class SimpleAudioPlayer {
private Player audioPlayer = null;//建立一个播放接口
public SimpleAudioPlayer(URL url) throws Exception{//创建一个准备Player,准备好播放
audioPlayer = Manager.createRealizedPlayer(url);
}
@SuppressWarnings("deprecation")
public SimpleAudioPlayer(File file) throws MalformedURLException, Exception{//将本地文件改为URL
this(file.toURL());
}
public void play(){//直接调用播放方法就可以
audioPlayer.start();
}
public void stop(){//停止的时候一定要释放资源
audioPlayer.stop();
audioPlayer.close();
}
public static void main(String [] args) throws MalformedURLException, Exception{
File file = new File("d://1.mp3");
SimpleAudioPlayer Player = new SimpleAudioPlayer(file);
Player.play();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有