void on_pause_activate(GtkToggleAction * action, gpointer user_data) { gboolean pause = gtk_toggle_action_get_active(action); if (player_is_paused(get_player(app)) == pause) return; player_pause(get_player(app)); }
void CAMLPlayer::Pause() { CLog::Log(LOGDEBUG, "CAMLPlayer::Pause"); CSingleLock lock(m_aml_csection); if ((m_pid < 0) && m_StopPlaying) return; if (m_paused) player_resume(m_pid); else player_pause(m_pid); m_paused = !m_paused; }
void CplayerDlg::OnLButtonDown(UINT nFlags, CPoint point) { if (point.y > m_rtClient.bottom - 8) { LONGLONG total = 1; player_getparam(g_hplayer, PARAM_MEDIA_DURATION, &total); player_seek(g_hplayer, total * point.x / m_rtClient.right); } else { if (!m_bPlayPause) player_pause(g_hplayer); else player_play(g_hplayer); m_bPlayPause = !m_bPlayPause; } CDialog::OnLButtonDown(nFlags, point); }
/* * Class: com_farcore_playerservice_MediaPlayer * Method: pause * Signature: (I)I */ JNIEXPORT jint JNICALL Java_com_farcore_playerservice_AmPlayer_pause (JNIEnv *env, jobject obj, jint pid){ LOGI("player pause"); player_pause(pid); return 0; }
/* * Class: com_rockcarry_ffplayer_MediaPlayer * Method: nativePause * Signature: (J)V */ static void JNICALL nativePause(JNIEnv *env, jobject obj, jlong hplayer) { DO_USE_VAR(env); DO_USE_VAR(obj); player_pause((void*)hplayer); }
/** * Handler to check user input, and see if it matches any avaible commands. * Will call the right methods for executing commands */ void handle_keyboard(sp_session *session, struct play_queue* node) { char buffer[1024]; fgets(buffer, sizeof(buffer), stdin); strtok(buffer, "\n"); if (strcmp(buffer, "search") == 0) { player_reset(); run_search(session); } else if ((strcmp(buffer, "list") == 0) || (strcmp(buffer, "ls") == 0 )) { print_playlists(session, pc); } else if(strcmp(buffer, "qshuffle") == 0) { queue_shuffle(); } else if (strcmp(buffer, "queueadd") == 0) { sp_playlist* pl = parse_play_command(session, buffer, node); printf("done finding playlist \n"); if(pl != NULL) printf("queueadd: %s\n", sp_playlist_name(pl)); else { printf("no playlist\n"); return; } int index; char input[10]; fputs("Song number: ", stdout); fgets(input, sizeof(input) - 1, stdin); sscanf(input, "%d", &index); if(sp_playlist_num_tracks(pl) < index) { printf("index too high!\n"); return; } sp_track* track = pl_find_song_by_id(pl, index); if(track != NULL) queue_add_first(track); } else if (strcmp(buffer, "list songs") == 0 ) { //release all threads sp_playlist* pl = playlist_find_by_num(session, pc); print_tracks_in_playlist(session, pl); } else if (strcmp(buffer, "help") == 0) { print_commands(); } else if (strcmp(buffer, "queue") == 0) { queue_print(node); } else if (strcmp(buffer, "shuffle mode") == 0) { print_commands(); } else if(strncmp(buffer, "play", strlen("play")) == 0) { player_reset(); sp_playlist* pl = parse_play_command(session, buffer, node); if(pl!=NULL) queue_add_playlist(pl); else { printf("ERROR playlist is null\n"); return; } queue_go_next(session); } else if(strncmp(buffer, "shuffle", strlen("shuffle")) == 0) { player_reset(); shuffle_mode = TRUE; sp_playlist* pl = parse_play_command(session, buffer, node); if(pl!=NULL) queue_add_playlist(pl); else { printf("ERROR playlist is null\n"); return; } queue_shuffle(); queue_go_next(session); } else if(strcmp(buffer, "pause") == 0 || strcmp(buffer, "p") == 0) { player_pause(session); play_info(); } else if (strcmp(buffer, "next") == 0 || strcmp(buffer, "n") == 0) { end_track(session); } else if (strcmp(buffer, "stop") == 0) { } else if (strcmp(buffer, "info") == 0) { play_info(); } else if (strcmp(buffer, "quit") == 0) { queue_free(); quit_program(session); } else { printf("Unkown command!\n"); } printf("> "); fflush(stdout); return; }
int main(int argc,char *argv[]) { play_control_t *pCtrl = NULL; int pid; int pos = 0; int speed = 0; int tmpneedexit = 0; int ret = -1; media_info_t minfo; char tmpcommand[TMP_COMMAND_MAX]; EMU_STEP tmpstep = EMU_STEP_MENU; pCtrl = (play_control_t*)malloc(sizeof(play_control_t)); memset(pCtrl,0,sizeof(play_control_t)); memset(&minfo,0,sizeof(media_info_t)); if(argc<2) { printf("usage:player file\n"); return -1; } player_init(); set_display_axis(0); //move osd out of screen to set video layer out player_register_update_callback(&pCtrl->callback_fn,&update_player_info,1000); printf("player callback register....\n"); pCtrl->file_name = strdup(argv[1]); //pCtrl->nosound = 1; // if disable audio...,must call this api pCtrl->video_index = -1;// MUST pCtrl->audio_index = -1;// MUST pCtrl->sub_index = -1;/// MUST pCtrl->hassub = 1; // enable subtitle //just open a buffer,just for p2p,http,etc... //pCtrl->auto_buffing_enable = 1; // pCtrl->buffing_min = 0.001; // pCtrl->buffing_middle = 0.02; // pCtrl->buffing_max = 0.9; pCtrl->t_pos = -1; // start position, if live streaming, need set to -1 pCtrl->need_start = 0; // if 0,you can omit player_start_play API.just play video/audio immediately. if 1,need call "player_start_play" API; pid=player_start(pCtrl,0); if(pid<0) { printf("player start failed!error=%d\n",pid); return -1; } signal(SIGSEGV, signal_handler); //SYS_disable_osd0(); while((!tmpneedexit)&&(!PLAYER_THREAD_IS_STOPPED(player_get_state(pid)))){ switch (tmpstep) { case EMU_STEP_PAUSE: player_pause(pid); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_RESUME: player_resume(pid); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_SEEK: printf("will seek position:100\n"); pos = 100; player_timesearch(pid,pos); tmpstep = EMU_STEP_MENU; break; break; case EMU_STEP_STOP: player_stop(pid); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_FF: printf("please input fastforward speed:\n"); speed = 1; player_forward(pid,speed); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_RR: printf("please input fastrewind speed:"); speed = 1; player_backward(pid,speed); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_SETLOOP: player_loop(pid); tmpstep = EMU_STEP_MENU; break; case EMU_STEP_EXIT: player_exit(pid); tmpneedexit = 1; break; case EMU_STEP_START: player_start_play(pid); //SYS_set_tsync_enable(0);///< f no sound,can set to be 0 tmpstep = EMU_STEP_MENU; break; case EMU_STEP_GETAVMEDIAINFO: if(pid>=0){ if(player_get_state(pid) > PLAYER_INITOK) { ret = player_get_media_info(pid,&minfo); if(ret==0) _media_info_dump(&minfo); } } tmpstep = EMU_STEP_MENU; break; case EMU_STEP_MENU: do { printf(SCREEN_SPLITER); printf(" player benchmark tool for android v2.0\n"); printf(SCREEN_SPLITER); printf("* Please choose one option *\r\n"); printf("* 0 show main menu *\r\n"); printf("* a start play *\r\n"); printf("* s get media info *\r\n"); printf("* 1 Pause play *\r\n"); printf("* 2 Resume play *\r\n"); printf("* 3 Stop play *\r\n"); printf("* 4 Fastforward *\r\n"); printf("* 5 Fastrewind *\r\n"); printf("* 6 Seek *\r\n"); printf("* 7 Set repeat *\r\n"); printf("* 8 Quit tools *\r\n"); printf(SCREEN_SPLITER); printf("please input you choice:"); memset(tmpcommand,0,TMP_COMMAND_MAX); scanf ("%s",tmpcommand); if (strcmp(tmpcommand,"1")==0){ tmpstep = EMU_STEP_PAUSE; } if (strcmp(tmpcommand,"0")==0){ sleep(1); tmpstep = EMU_STEP_MENU; } else if (strcmp(tmpcommand,"2")==0){ tmpstep = EMU_STEP_RESUME; } else if (strcmp(tmpcommand,"3")==0){ tmpstep = EMU_STEP_STOP; } else if (strcmp(tmpcommand,"4")==0){ tmpstep = EMU_STEP_FF; } else if (strcmp(tmpcommand,"5")==0){ tmpstep = EMU_STEP_RR; } else if (strcmp(tmpcommand,"6")==0) { tmpstep = EMU_STEP_SEEK; } else if (strcmp(tmpcommand,"7")==0) { tmpstep = EMU_STEP_SETLOOP; } else if (strcmp(tmpcommand,"8")==0) { tmpstep = EMU_STEP_EXIT; } else if (strcmp(tmpcommand,"a")==0) { tmpstep = EMU_STEP_START; } else if (strcmp(tmpcommand,"s")==0){ tmpstep = EMU_STEP_GETAVMEDIAINFO; } }while (0); break; } usleep(100*1000); signal(SIGCHLD, SIG_IGN); signal(SIGTSTP, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGHUP, signal_handler); signal(SIGTERM, signal_handler); signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); signal(SIGQUIT, signal_handler); } set_display_axis(1); //recover osd free(pCtrl->file_name); free(pCtrl); printf("...........player exit,~,byeybe...........\n"); return 0; }
void player_pause_playback(void) { if (consumer_status == CS_PLAYING) player_pause(); }