uni代码:
let MediaPlayer = plus.android.importClass("android.media.MediaPlayer");
var audioPlayer = new MediaPlayer()
audioPlayer.setDataSource("https://www.veelink.com/music/test.mp3"); //指定音频文件路径
audioPlayer.prepare(); //初始化播放器MediaPlayer
audioPlayer.start();
android原生代码:
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource("https://www.veelink.com/music/test.mp3");
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
0 个回复