Interface Class Name | Description |
TAVEditor | SDK operation entry class. |
Method | Parameters | Return Value | Description |
addBgm(String path, long startAtVideoTimeUS, long startTimeUS, long duration) | path: music file pathstartAtVideoTimeUS: start time in the video (us)startTimeUS: music start time (us)duration: playback duration (us) | int | Add background music and return an ID |
removeBgm(int bgmID) | bgmID: background music ID | boolean | Remove background music |
updateBgmPlayOffset(int bgmID, long videoStartTime) | bgmID: background music IDvideoStartTime: video position (us) | void | Adjust background music position in the video |
updateBgmPlayRange(int bgmID, long startTime, long duration) | bgmID: background music IDstartTime: start time (us)duration: playback duration (us) | void | Adjust background music play range |
setBgmVolume(int bgmID, float volume) | bgmID: background music IDvolume: volume recommended range 0-3f | void | Set individual background music volume |
setAllBgmVolume(float volume) | volume: volume recommended range 0-3f | void | Set all background music volume |
getBgmVolume(int bgmID) | bgmID: background music ID | float | Get background music volume |
setBgmSpeed(int bgmID, float speed) | bgmID: background music IDspeed: playback speed | void | Set background music playback speed |
getBgmSpeed(int bgmID) | bgmID: background music ID | float | Get background music playback speed |
/*** Add background music** @param path Music file path* @param startAtVideoTimeUS Time point in the video where background music appears (microseconds)* @param startTimeUS Start playback time of the background music itself (microseconds)* @param duration Background music playback duration (microseconds)* @return Unique background music ID*/int bgmId = editor.addBgm(path, startAtVideoTimeUS, startTimeUS, duration);
/*** Remove background music** @param bgmId Background music ID* @return Whether deletion was successful*/boolean success = editor.removeBgm(bgmId);
/*** Adjust background music position in the video** @param bgmId Background music ID* @param videoStartTime New video time point (microseconds)*/editor.updateBgmPlayOffset(bgmId, videoStartTime);
/*** Adjust background music play range** @param bgmId Background music ID* @param startTime New start time (microseconds)* @param duration New playback duration (microseconds)*/editor.updateBgmPlayRange(bgmId, startTime, duration);
/*** Set individual background music volume** @param bgmId Background music ID* @param volume Volume value, recommended range: 0-3f*/editor.setBgmVolume(bgmId, volume);/*** Set all background music volume** @param volume Volume value, recommended range: 0-3f*/editor.setAllBgmVolume(volume);/*** Get background music volume** @param bgmId Background music ID* @return Current volume value*/float volume = editor.getBgmVolume(bgmId);
/*** Set background music playback speed** @param bgmId Background music ID* @param speed Playback speed (1.0 = normal speed)*/editor.setBgmSpeed(bgmId, speed);/*** Get background music playback speed** @param bgmId Background music ID* @return Current playback speed*/float speed = editor.getBgmSpeed(bgmId);
// Add background music (starts at 2s in video, plays the first 3s of music, lasts 4s)int bgmId = editor.addBgm("/sdcard/music.mp3",2_000_000, // Start time in video0, // Music start time4_000_000); // Playback duration// Adjust volume to 70%editor.setBgmVolume(bgmId, 0.7f);// Adjust playback speed to 1.5xeditor.setBgmSpeed(bgmId, 1.5f);// Start playing music at 5s in the videoeditor.updateBgmPlayOffset(bgmId, 5_000_000);// Adjust music play range (start at 1s, play for 2s)editor.updateBgmPlayRange(bgmId,1_000_000, // Start time2_000_000); // Playback duration// Remove background musicboolean success = editor.removeBgm(bgmId);// Get background music volume by IDfloat currentVolume = editor.getBgmVolume(bgmId);
フィードバック