Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event_command: add songpause and songresume events #748

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/ui_act.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,28 +429,54 @@ BarUiActCallback(BarUiActSkipSong) {
/* play
*/
BarUiActCallback(BarUiActPlay) {
bool tookAction = false;
PianoReturn_t pRet = PIANO_RET_OK;;
CURLcode wRet = CURLE_OK;

pthread_mutex_lock (&app->player.lock);
app->player.doPause = false;
pthread_cond_broadcast (&app->player.cond);
if (app->player.doPause) {
tookAction = true;
app->player.doPause = false;
pthread_cond_broadcast (&app->player.cond);
}
pthread_mutex_unlock (&app->player.lock);
if (tookAction) {
BarUiActDefaultEventcmd("songresume");
}
}

/* pause
*/
BarUiActCallback(BarUiActPause) {
bool tookAction = false;
PianoReturn_t pRet = PIANO_RET_OK;;
CURLcode wRet = CURLE_OK;

pthread_mutex_lock (&app->player.lock);
app->player.doPause = true;
pthread_cond_broadcast (&app->player.cond);
if (!app->player.doPause) {
tookAction = true;
app->player.doPause = true;
pthread_cond_broadcast (&app->player.cond);
}
pthread_mutex_unlock (&app->player.lock);
if (tookAction) {
BarUiActDefaultEventcmd("songpause");
}
}

/* toggle pause
*/
BarUiActCallback(BarUiActTogglePause) {
bool paused;
PianoReturn_t pRet = PIANO_RET_OK;;
CURLcode wRet = CURLE_OK;

pthread_mutex_lock (&app->player.lock);
app->player.doPause = !app->player.doPause;
paused = app->player.doPause;
pthread_cond_broadcast (&app->player.cond);
pthread_mutex_unlock (&app->player.lock);
BarUiActDefaultEventcmd(paused ? "songpause" : "songresume");
}

/* rename current station
Expand Down
Loading