赞
踩
播放短视频
得到文件之后使用音频编辑软件进行编辑,得到将音频文件之后将这个文件放置到项目的midia文件夹中:
鸿蒙应用开发可以使用SoundPlayer播放音频文件:
private void startSound(float speed, OnPlayListener listener) {
soundPlayer = new SoundPlayer(AudioManager.AudioVolumeType.STREAM_MUSIC.getValue());
soundId = soundPlayer.createSound(getContext(), ResourceTable.Media_1tick);
soundPlayer.setOnCreateCompleteListener((soundPlayer1, i, i1) -> {
taskId = soundPlayer.play(soundId);
soundPlayer.setVolume(taskId, 1.0f);
soundPlayer.setLoop(taskId, -1);
soundPlayer.setPlaySpeedRate(taskId, speed);
if(listener != null){
listener.onPlay();
}
}
}
1.private void startSound(float speed, OnPlayListener listener) {
soundPlayer = new SoundPlayer(AudioManager.AudioVolumeType.STREAM_MUSIC.getValue());
soundId = soundPlayer.createSound(getContext(), ResourceTable.Media_1tick);
soundPlayer.setOnCreateCompleteListener((soundPlayer1, i, i1) -> {
taskId = soundPlayer.play(soundId);
soundPlayer.setVolume(taskId, 1.0f);
soundPlayer.setLoop(taskId, -1);
soundPlayer.setPlaySpeedRate(taskId, speed);
if(listener != null){
listener.onPlay();
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。