gpt4 book ai didi

java - super 强大的 SDK Android

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:36:11 25 4
gpt4 key购买 nike

您好,我想创建一个具有超强 SDK 的播放器,但我无法退出循环。当歌曲结束时,他又开始播放,因为它被删除了?

С++ void for start and pause playing;

void SuperpoweredExample::onPlayPause(bool play) {
pthread_mutex_lock(&mutex);
if (!play) {
playerA->pause();
playerB->pause();
} else {
bool masterIsA = (crossValue <= 0.5f);
playerA->play(!masterIsA);
playerB->play(masterIsA);
};
pthread_mutex_unlock(&mutex);
}

This void in JAVA

public void SuperpoweredExample_PlayPause(View button) {  // Play/pause.
playing = !playing;
onPlayPause(playing);
Button b = (Button) findViewById(R.id.playPause);
b.setText(playing ? "Pause" : "Play");
}

And player initialize and play options in C++

SuperpoweredAdvancedAudioPlayer *playerA = *((SuperpoweredAdvancedAudioPlayer **)clientData);
playerA->setBpm(126.0f);
playerA->setFirstBeatMs(1);
playerA->setPosition(playerA->firstBeatMs, false, false);
playerA->exitLoop(); // not work
playerA->looping = false; // not work
playerA->togglePlayback();

playerA = new SuperpoweredAdvancedAudioPlayer(&playerA , playerEventCallbackA, samplerate, 0);
playerA->open(path, params[0], params[1]);

最佳答案

在你的playerEventCallbackA方法中处理播放状态

playerA = new SuperpoweredAdvancedAudioPlayer(&playerA , playerEventCallbackA, samplerate, 0);

主要播放器事件的回调。如果您查看 SuperpoweredAdvancedAudioPlayer.h 类,您会发现

typedef enum SuperpoweredAdvancedAudioPlayerEvent {
SuperpoweredAdvancedAudioPlayerEvent_LoadSuccess,
SuperpoweredAdvancedAudioPlayerEvent_LoadError,
SuperpoweredAdvancedAudioPlayerEvent_EOF,
SuperpoweredAdvancedAudioPlayerEvent_JogParameter,
SuperpoweredAdvancedAudioPlayerEvent_DurationChanged,
} SuperpoweredAdvancedAudioPlayerEvent;

当您收到 SuperpoweredAdvancedAudioPlayerEvent_EOF 事件时,您可以暂停播放或做任何您想做的事情。

例如

    static void playerEventCallbackA(void *clientData, SuperpoweredAdvancedAudioPlayerEvent event, void *value) {
SuperpoweredAdvancedAudioPlayer *playerA = *((SuperpoweredAdvancedAudioPlayer **)clientData);
if (event == SuperpoweredAdvancedAudioPlayerEvent_LoadSuccess) {
// handle player prepared
} else if (event == SuperpoweredAdvancedAudioPlayerEvent_LoadError) {
// handle error with player
} else if (event == SuperpoweredAdvancedAudioPlayerEvent_EOF && !loopingA) {
playerA->pause();
}
}

希望对您有所帮助。

关于java - super 强大的 SDK Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33239720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com