int main(int argc, char **argv) { d_init("pong", "Pong!", NULL); if (!init()) { fprintf(stderr, "libDarnit didn't init\n"); return -1; } d_render_clearcolor_set(0, 0, 192); for (;;) { player_loop(); ball_loop(); d_render_begin(); d_render_tile_blit(p.player_ts, 0, p.player.x, p.player.y / 1000); d_render_end(); d_loop(); } d_quit(); return 0; }
void game_handle(DARNIT_KEYS *keys, DARNIT_MOUSE *mouse) { if(keys->start||keys->select) gamestate(GAMESTATE_PAUSE); map_loop(); player_loop(keys); if(boss_shooting&&(d_time_get()>boss_shooting)) { boss_shooting=0; particle_emitter_stop(boss_emitter[0]); particle_emitter_stop(boss_emitter[1]); } }
/* * Class: com_farcore_playerservice_MediaPlayer * Method: setRepeat * Signature: (II)I */ JNIEXPORT jint JNICALL Java_com_farcore_playerservice_AmPlayer_setRepeat (JNIEnv *env, jobject obj, jint pid, jint isRepeat){ jint ret = -1; if(isRepeat>0){ LOGI("set loop play"); ret = player_loop(pid); }else{ LOGI("stop to play looply"); ret = player_noloop(pid); } return ret; }
int launch_game(t_lemipc *lemipc) { signal(SIGINT, catch_signal); srand(time(NULL)); lock_sem(lemipc->game->sem_id); init_player(lemipc); unlock_sem(lemipc->game->sem_id); player_loop(lemipc); lemipc->game->map[lemipc->player.pos.y][lemipc->player.pos.x] = 0; if (count_players(lemipc) == 0) { printf("Winner is team %d\n", lemipc->player.team); free_ipcs(lemipc); } return (0); }
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; }