static void read_cmd(menu_t* menu,int cmd) { switch(cmd) { case MENU_CMD_RIGHT: case MENU_CMD_OK: { int d = 1; char str[15]; play_tree_t* i; mp_cmd_t* c; play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); if(playtree_iter->tree == mpriv->p.current->pt) break; if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) snprintf(str,15,"pt_up_step 1"); else { for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { if(i == mpriv->p.current->pt) break; d++; } if(i == NULL) { d = -1; for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { if(i == mpriv->p.current->pt) break; d--; } if(i == NULL) { mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Can't find the target item ????\n"); break; } } snprintf(str,15,"pt_step %d",d); } c = mp_input_parse_cmd(str); if(c) { if(mpriv->auto_close) mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd("menu hide")); mp_input_queue_cmd(menu->input_ctx, c); } else mp_tmsg(MSGT_GLOBAL,MSGL_WARN,"[MENU] Failed to build command: %s.\n",str); } break; default: menu_list_read_cmd(menu,cmd); } }
/** * Generates a mouse movement message if those are enable and sends it * to the "main" MPlayer. * * \param posx new x position of mouse * \param posy new y position of mouse */ void vo_mouse_movement(int posx, int posy) { char cmd_str[40]; if (!enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); }
/** * Sends MPlayer a command to change aspect to the requested value. * @param new_aspect desired new aspect, < 0 means restore original. */ void change_movie_aspect(float new_aspect) { char cmd_str[64]; if (new_aspect < 0) new_aspect = old_movie_aspect; our_aspect_change = 1; snprintf(cmd_str, sizeof(cmd_str), "switch_ratio %f", new_aspect); mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); }
void menu_audio(ULONG menucode) { switch (ITEMNUM(menucode)) { case ID_mute: mp_input_queue_cmd(mp_input_parse_cmd("mute")); break; case ID_volume_up: mplayer_put_key(KEY_VOLUME_UP); break; case ID_volume_down: mplayer_put_key(KEY_VOLUME_DOWN); break; } }
/* this function gets called by the gui to update mplayer */ static void guiSetEvent(int event) { if(guiInfo.mpcontext) mixer = mpctx_get_mixer(guiInfo.mpcontext); switch(event) { case evPlay: case evPlaySwitchToPause: case evPauseSwitchToPlay: uiPlay(); break; case evPause: uiPause(); break; #ifdef CONFIG_DVDREAD case evPlayDVD: { static char dvdname[MAX_PATH]; guiInfo.Track = 1; guiInfo.Chapter = 1; guiInfo.Angle = 1; guiInfo.NewPlay = GUI_FILE_SAME; #ifdef __WINE__ // dvd_device is in the Windows style (D:\), which needs to be // converted for MPlayer, so that it will find the device in the // Linux filesystem. dvd_device = unix_device(dvd_device); #endif uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); dvdname[0] = 0; strcat(dvdname, "DVD Movie"); GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); capitalize(dvdname); mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); mygui->playlist->clear_playlist(mygui->playlist); mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); uiPlay(); break; } #endif #ifdef CONFIG_CDDA case evPlayCD: { int i; char track[10]; char trackname[10]; #ifdef CONFIG_LIBCDIO cdrom_drive_t *cd; #else cdrom_drive *cd; #endif int i_tracks; #ifdef __WINE__ // cdrom_device is in the Windows style (D:\), which needs to be // converted for MPlayer, so that it will find the device in the // Linux filesystem. cdrom_device = unix_device(cdrom_device); #endif cd = cdda_identify(cdrom_device, 0, NULL); if (cd) { if (cdda_open(cd) != 0) { cdda_close(cd); cd = NULL; } } if(!cd) { printf("Couldn't find a driver.\n"); break; } i_tracks = cdda_tracks(cd); mygui->playlist->clear_playlist(mygui->playlist); for(i=0;i<i_tracks;i++) { sprintf(track, "cdda://%d", i+1); sprintf(trackname, "Track %d", i+1); mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); } cdda_close(cd); mygui->startplay(mygui); break; } #endif case evFullScreen: mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); break; case evExit: { /* We are asking mplayer to exit, later it will ask us after uninit is made this should be the only safe way to quit */ mygui->activewidget = NULL; mp_input_queue_cmd(mp_input_parse_cmd("quit")); break; } case evStop: if(guiInfo.Playing) gui(GUI_SET_STATE, (void *) GUI_STOP); break; case evSetMoviePosition: { rel_seek_secs = guiInfo.Position / 100.0f; abs_seek_pos = 3; break; } case evForward10sec: { rel_seek_secs = 10.0f; abs_seek_pos = 0; break; } case evBackward10sec: { rel_seek_secs = -10.0f; abs_seek_pos = 0; break; } case evSetBalance: case evSetVolume: { float l,r; if (guiInfo.Playing == GUI_STOP) break; if (guiInfo.Balance == 50.0f) mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); if (l > guiInfo.Volume) l=guiInfo.Volume; if (r > guiInfo.Volume) r=guiInfo.Volume; mixer_setvolume(mixer, l, r); /* Check for balance support on mixer - there is a better way ?? */ if (r != l) { mixer_getvolume(mixer, &l, &r); if (r == l) { mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); guiInfo.Balance = 50.0f; } } break; } case evMute: { mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); cmd->id=MP_CMD_MUTE; cmd->name=strdup("mute"); mp_input_queue_cmd(cmd); break; } case evLoadPlay: { switch(guiInfo.StreamType) { case STREAMTYPE_DVD: { guiInfo.NewPlay = GUI_FILE_SAME; gui(GUI_SET_STATE, (void *) GUI_PLAY); break; } default: { guiInfo.NewPlay = GUI_FILE_NEW; update_playlistwindow(); uiGotoTheNext = guiInfo.Playing? 0 : 1; gui(GUI_SET_STATE, (void *) GUI_STOP); gui(GUI_SET_STATE, (void *) GUI_PLAY); break; } } break; } case evNext: uiNext(); break; case evPrev: uiPrev(); break; } }
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11, struct mp_fifo *key_fifo, struct input_ctx *input_ctx) { char **vo_list = opts->video_driver_list; int i; struct vo *vo = talloc_ptrtype(NULL, vo); struct vo initial_values = { .opts = opts, .x11 = x11, .key_fifo = key_fifo, .input_ctx = input_ctx, .event_fd = -1, .registered_fd = -1, }; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0]) while (vo_list[0][0]) { char *name = strdup(vo_list[0]); vo_subdevice = strchr(name,':'); if (!strcmp(name, "pgm")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n"); if (!strcmp(name, "md5")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The md5 video output driver has been replaced by -vo md5sum.\n"); if (vo_subdevice) { vo_subdevice[0] = 0; ++vo_subdevice; } for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; const vo_info_t *info = video_driver->info; if (!strcmp(info->short_name, name)) { // name matches, try it *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) { free(name); return vo; // success! } talloc_free_children(vo); } } // continue... free(name); ++vo_list; if (!(vo_list[0])) return NULL; // do NOT fallback to others } // now try the rest... vo_subdevice = NULL; for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) return vo; // success! talloc_free_children(vo); } free(vo); return NULL; } static int event_fd_callback(void *ctx, int fd) { struct vo *vo = ctx; vo_check_events(vo); return MP_INPUT_NOTHING; } int vo_config(struct vo *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { struct MPOpts *opts = vo->opts; panscan_init(vo); aspect_save_orig(vo, width, height); aspect_save_prescale(vo, d_width, d_height); if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { aspect(vo, &d_width, &d_height, A_NOZOOM); vo->dx = (int)(opts->vo_screenwidth - d_width) / 2; vo->dy = (int)(opts->vo_screenheight - d_height) / 2; geometry(&vo->dx, &vo->dy, &d_width, &d_height, opts->vo_screenwidth, opts->vo_screenheight); geometry_xy_changed |= xinerama_screen >= 0; vo->dx += xinerama_x; vo->dy += xinerama_y; vo->dwidth = d_width; vo->dheight = d_height; } int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, title, format); vo->config_ok = (ret == 0); vo->config_count += vo->config_ok; if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) { mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback, NULL, vo); vo->registered_fd = vo->event_fd; } return ret; } /** * \brief lookup an integer in a table, table must have 0 as the last key * \param key key to search for * \result translation corresponding to key or "to" value of last mapping * if not found. */ int lookup_keymap_table(const struct mp_keymap *map, int key) { while (map->from && map->from != key) map++; return map->to; } /** * \brief helper function for the kind of panscan-scaling that needs a source * and destination rectangle like Direct3D and VDPAU */ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size, int *src_start, int *src_end, int *dst_start, int *dst_end) { if (scaled_src_size > dst_size) { int border = src_size * (scaled_src_size - dst_size) / scaled_src_size; // round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards border = (border / 2 + 1) & ~1; *src_start = border; *src_end = src_size - border; *dst_start = 0; *dst_end = dst_size; } else { *src_start = 0; *src_end = src_size; *dst_start = (dst_size - scaled_src_size) / 2; *dst_end = *dst_start + scaled_src_size; } } /** * Calculate the appropriate source and destination rectangle to * get a correctly scaled picture, including pan-scan. * Can be extended to take future cropping support into account. * * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL * \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires, * may be NULL and only left and top are currently valid. */ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop) { static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; int scaled_width = 0; int scaled_height = 0; if (!crop) crop = &no_crop; src_width -= crop->left + crop->right; src_height -= crop->top + crop->bottom; if (src_width < 2) src_width = 2; if (src_height < 2) src_height = 2; dst->left = 0; dst->right = vo->dwidth; dst->top = 0; dst->bottom = vo->dheight; src->left = 0; src->right = src_width; src->top = 0; src->bottom = src_height; if (borders) { borders->left = 0; borders->top = 0; } if (aspect_scaling()) { aspect(vo, &scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(vo); scaled_width += vo->panscan_x; scaled_height += vo->panscan_y; if (borders) { borders->left = (vo->dwidth - scaled_width ) / 2; borders->top = (vo->dheight - scaled_height) / 2; } src_dst_split_scaling(src_width, vo->dwidth, scaled_width, &src->left, &src->right, &dst->left, &dst->right); src_dst_split_scaling(src_height, vo->dheight, scaled_height, &src->top, &src->bottom, &dst->top, &dst->bottom); } src->left += crop->left; src->right += crop->left; src->top += crop->top; src->bottom += crop->top; src->width = src->right - src->left; src->height = src->bottom - src->top; dst->width = dst->right - dst->left; dst->height = dst->bottom - dst->top; } /** * Generates a mouse movement message if those are enable and sends it * to the "main" MPlayer. * * \param posx new x position of mouse * \param posy new y position of mouse */ void vo_mouse_movement(struct vo *vo, int posx, int posy) { char cmd_str[40]; if (!enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(cmd_str)); }
static void read_cmd(menu_t* menu, int cmd) { list_entry_t *elem; mp_cmd_t* c; char *cmd_name; switch(cmd) { case MENU_CMD_RIGHT: case MENU_CMD_OK: { elem = mpriv->p.current; if(mpriv->level == 1) { mpriv->card = mpriv->p.current->num; mpriv->level = 2; menu_list_uninit(menu, free_entry); fill_menu(menu); } else { dvb_priv_t *dvbp = (dvb_priv_t*) mpriv->config->priv; cmd_name = malloc(25 + strlen(elem->p.txt)); if(dvbp != NULL) sprintf(cmd_name, "dvb_set_channel %d %d", elem->num, mpriv->card); else sprintf(cmd_name, "loadfile 'dvb://%d@%s'", mpriv->card+1, elem->p.txt); c = mp_input_parse_cmd(cmd_name); if(c) { if (mpriv->auto_close) mp_input_queue_cmd (mp_input_parse_cmd ("menu hide")); mp_input_queue_cmd(c); } } } break; case MENU_CMD_LEFT: case MENU_CMD_CANCEL: { elem = mpriv->p.current; menu_list_uninit(menu, free_entry); if(mpriv->config->count > 1) mpriv->level--; else mpriv->level = 0; if(mpriv->level > 0) { fill_menu(menu); break; } } default: menu_list_read_cmd(menu, cmd); } }
void run_command_android(char *command){ mp_input_queue_cmd(mp_input_parse_cmd(command)); }
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi = NULL; if (vf->priv->passthrough) { dmpi=vf_get_image(vf->next, IMGFMT_MPEGPES, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); dmpi->planes[0]=mpi->planes[0]; return vf_next_put_image(vf,dmpi, pts); } if(vf->priv->current->show || (vf->priv->current->parent && vf->priv->current->parent->show)) { // Close all menu who requested it while(vf->priv->current->cl && vf->priv->current != vf->priv->root) { menu_t* m = vf->priv->current; vf->priv->current = m->parent ? m->parent : vf->priv->root; menu_close(m); } // Step 1 : save the picture while(go2pause == 1) { static char delay = 0; // Hack : wait the 2 frame to be sure to show the right picture delay ^= 1; // after a seek if(!delay) break; if(pause_mpi && (mpi->w != pause_mpi->w || mpi->h != pause_mpi->h || mpi->imgfmt != pause_mpi->imgfmt)) { free_mp_image(pause_mpi); pause_mpi = NULL; } if(!pause_mpi) pause_mpi = alloc_mpi(mpi->w,mpi->h,mpi->imgfmt); copy_mpi(pause_mpi,mpi); mp_input_queue_cmd(mp_input_parse_cmd("pause")); go2pause = 2; break; } // Grab // Ungrab the keys if(!mp_input_key_cb && vf->priv->current->show) mp_input_key_cb = key_cb; if(mp_input_key_cb && !vf->priv->current->show) mp_input_key_cb = NULL; if(mpi->flags&MP_IMGFLAG_DIRECT) dmpi = mpi->priv; else { dmpi = vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w,mpi->h); copy_mpi(dmpi,mpi); } menu_draw(vf->priv->current,dmpi); } else { if(mp_input_key_cb) mp_input_key_cb = NULL; if(mpi->flags&MP_IMGFLAG_DIRECT) dmpi = mpi->priv; else { dmpi = vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w,mpi->h); dmpi->stride[0] = mpi->stride[0]; dmpi->stride[1] = mpi->stride[1]; dmpi->stride[2] = mpi->stride[2]; dmpi->planes[0] = mpi->planes[0]; dmpi->planes[1] = mpi->planes[1]; dmpi->planes[2] = mpi->planes[2]; dmpi->priv = mpi->priv; } } return vf_next_put_image(vf,dmpi, pts); }
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { RECT r; POINT p; int mpkey; switch (message) { case WM_ERASEBKGND: // no need to erase background seperately return 1; case WM_PAINT: event_flags |= VO_EVENT_EXPOSE; break; case WM_MOVE: p.x = 0; p.y = 0; ClientToScreen(vo_window, &p); vo_dx = p.x; vo_dy = p.y; break; case WM_SIZE: event_flags |= VO_EVENT_RESIZE; GetClientRect(vo_window, &r); vo_dwidth = r.right; vo_dheight = r.bottom; break; case WM_WINDOWPOSCHANGING: if (vo_keepaspect && !vo_fs && WinID < 0) { WINDOWPOS *wpos = lParam; int xborder, yborder; r.left = r.top = 0; r.right = wpos->cx; r.bottom = wpos->cy; AdjustWindowRect(&r, GetWindowLong(vo_window, GWL_STYLE), 0); xborder = (r.right - r.left) - wpos->cx; yborder = (r.bottom - r.top) - wpos->cy; wpos->cx -= xborder; wpos->cy -= yborder; aspect_fit(global_vo, &wpos->cx, &wpos->cy, wpos->cx, wpos->cy); wpos->cx += xborder; wpos->cy += yborder; } return 0; case WM_CLOSE: mplayer_put_key(KEY_CLOSE_WIN); break; case WM_SYSCOMMAND: switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n"); return 0; } break; case WM_KEYDOWN: mpkey = lookup_keymap_table(vk_map, wParam); if (mpkey) mplayer_put_key(mpkey); break; case WM_CHAR: mplayer_put_key(wParam); break; case WM_LBUTTONDOWN: if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) { mplayer_put_key(MOUSE_BTN0); break; } if (!vo_fs) { ReleaseCapture(); SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); return 0; } break; case WM_MBUTTONDOWN: if (!vo_nomouse_input) mplayer_put_key(MOUSE_BTN1); break; case WM_RBUTTONDOWN: if (!vo_nomouse_input) mplayer_put_key(MOUSE_BTN2); break; case WM_MOUSEMOVE: if (enable_mouse_movements) { char cmd_str[40]; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); mp_input_queue_cmd(global_vo->input_ctx, mp_input_parse_cmd(cmd_str)); } break; case WM_MOUSEWHEEL: if (!vo_nomouse_input) { int x = GET_WHEEL_DELTA_WPARAM(wParam); if (x > 0) mplayer_put_key(MOUSE_BTN3); else mplayer_put_key(MOUSE_BTN4); break; } } return DefWindowProc(hWnd, message, wParam, lParam); }
static void read_cmd(menu_t* menu,int cmd) { switch(cmd) { case MENU_CMD_CANCEL: if(mpriv->hide_time) mpriv->hide_ts = GetTimerMS(); else menu->show = 0; mpriv->show_ts = 0; return; case MENU_CMD_OK: { mp_cmd_t* c; if(mpriv->child) { char *str = mpriv->cur_history->buffer; int l = strlen(str); while(l > 0) { int w = write(mpriv->child_fd[0],str,l); if(w < 0) { mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError); break; } l -= w; str += w; } if(write(mpriv->child_fd[0],"\n",1) < 0) mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError); enter_cmd(menu); return; } c = mp_input_parse_cmd(mpriv->cur_history->buffer); enter_cmd(menu); if(!c) add_line(mpriv,"Invalid command try help"); else { switch(c->id) { case MP_CMD_CHELP: add_line(mpriv,"MPlayer console 0.01"); add_line(mpriv,"TODO: meaningful help message ;)"); add_line(mpriv,"Enter any slave command"); add_line(mpriv,"exit close this console"); break; case MP_CMD_CEXIT: menu->show = 0; menu->cl = 1; break; case MP_CMD_CHIDE: if(mpriv->hide_time) mpriv->hide_ts = GetTimerMS(); else menu->show = 0; mpriv->show_ts = 0; break; case MP_CMD_RUN: run_shell_cmd(menu,c->args[0].v.s); break; default: // Send the other commands to mplayer mp_input_queue_cmd(c); } } return; } case MENU_CMD_UP: if(mpriv->cur_history->prev) mpriv->cur_history = mpriv->cur_history->prev; break; case MENU_CMD_DOWN: if(mpriv->cur_history->next) mpriv->cur_history = mpriv->cur_history->next; break; } }
static void read_key(menu_t* menu,int c) { if(!mpriv->child || !mpriv->raw_child) switch(c) { case KEY_ESC: if(mpriv->hide_time) mpriv->hide_ts = GetTimerMS(); else menu->show = 0; mpriv->show_ts = 0; return; case KEY_ENTER: { mp_cmd_t* c; if(mpriv->child) { char *str = mpriv->cur_history->buffer; int l = strlen(str); while(l > 0) { int w = write(mpriv->child_fd[0],str,l); if(w < 0) { mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError); break; } l -= w; str += w; } if(write(mpriv->child_fd[0],"\n",1) < 0) mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError); enter_cmd(menu); return; } c = mp_input_parse_cmd(mpriv->cur_history->buffer); enter_cmd(menu); if(!c) add_line(mpriv,"Invalid command try help"); else { switch(c->id) { case MP_CMD_CHELP: add_line(mpriv,"MPlayer console 0.01"); add_line(mpriv,"TODO: meaningful help message ;)"); add_line(mpriv,"Enter any slave command"); add_line(mpriv,"exit close this console"); break; case MP_CMD_CEXIT: menu->show = 0; menu->cl = 1; break; case MP_CMD_CHIDE: if(mpriv->hide_time) mpriv->hide_ts = GetTimerMS(); else menu->show = 0; mpriv->show_ts = 0; break; case MP_CMD_RUN: run_shell_cmd(menu,c->args[0].v.s); break; default: // Send the other commands to mplayer mp_input_queue_cmd(c); } } return; } case KEY_DELETE: case KEY_BS: { unsigned int i = strlen(mpriv->cur_history->buffer); if(i > 0) mpriv->cur_history->buffer[i-1] = '\0'; return; } case KEY_UP: if(mpriv->cur_history->prev) mpriv->cur_history = mpriv->cur_history->prev; break; case KEY_DOWN: if(mpriv->cur_history->next) mpriv->cur_history = mpriv->cur_history->next; break; } if(mpriv->child && mpriv->raw_child) { write(mpriv->child_fd[0],&c,sizeof(int)); return; } if(isascii(c)) { int l = strlen(mpriv->cur_history->buffer); if(l >= mpriv->cur_history->size) { mpriv->cur_history->size += 255; mpriv->cur_history->buffer = realloc(mpriv->cur_history,mpriv->cur_history->size); } mpriv->cur_history->buffer[l] = (char)c; mpriv->cur_history->buffer[l+1] = '\0'; } }
int playtree_update_play(MPContext * mpctx, int index) { int i; play_tree_t *list = NULL, *entry = NULL, *last_entry = NULL; need_update_playtree = 0; if(playlist->trackcount <= 0) return -1; for(i = 0; i<(playlist->trackcount); i++) { entry = play_tree_new(); play_tree_add_file(entry, playlist->tracks[i]->filename); if(list) play_tree_append_entry(last_entry,entry); else list = entry; last_entry = entry; } entry = play_tree_new(); play_tree_set_child(entry,list); if (entry) { if(!mpctx->playtree_iter || !mpctx->playtree) { if (mpctx->playtree) // the playtree is always a node with one child. let's clear it play_tree_free_list(mpctx->playtree->child, 1); else mpctx->playtree=play_tree_new(); // .. or make a brand new playtree if (!mpctx->playtree) return -1; // couldn't make playtree! play_tree_set_child(mpctx->playtree, entry); /* Make iterator start at the top the of tree. */ mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mconfig); if (!mpctx->playtree_iter) return; // find the first real item in the tree if (play_tree_iter_step(mpctx->playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { // no items! play_tree_iter_free(mpctx->playtree_iter); mpctx->playtree_iter = NULL; } else { mpctx->eof = PT_NEXT_ENTRY; if(index > 0 && index < playlist->trackcount) { mpctx->play_tree_step = index; play_tree_iter_step(mpctx->playtree_iter,mpctx->play_tree_step,0); } filename = play_tree_iter_get_file(mpctx->playtree_iter, mpctx->eof); mp_input_queue_cmd(mp_input_parse_cmd("stop")); } } else { // Go back to the starting point. while (play_tree_iter_up_step(mpctx->playtree_iter, 0, 1) != PLAY_TREE_ITER_END) /* NOP */ ; play_tree_free_list(mpctx->playtree->child, 1); play_tree_set_child(mpctx->playtree, entry); pt_iter_goto_head(mpctx->playtree_iter); mpctx->eof = PT_NEXT_SRC; loop_break = 1; if(index > 0 && index < playlist->trackcount) { play_tree_iter_t *i = play_tree_iter_new_copy(mpctx->playtree_iter); if (play_tree_iter_step(i, index, 0) == PLAY_TREE_ITER_ENTRY) mpctx->eof = PT_NEXT_ENTRY; play_tree_iter_free(i); if (mpctx->eof == PT_NEXT_ENTRY) mpctx->play_tree_step = index; } } } return 0; }
void uiEvent(int ev, float param) { int iparam = (int)param; mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); float aspect; char cmd[40]; switch (ev) { /* user events */ case evExit: mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0); break; case evLoadURL: gtkShow(evLoadURL, NULL); break; case ivSetAudio: if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam) break; mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; case ivSetVideo: if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam) break; mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; case ivSetSubtitle: mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); break; #ifdef CONFIG_CDDA case ivSetCDTrack: guiInfo.Track = iparam; case evPlayCD: guiInfo.StreamType = STREAMTYPE_CDDA; goto play; #endif #ifdef CONFIG_VCD case ivSetVCDTrack: guiInfo.Track = iparam; case evPlayVCD: guiInfo.StreamType = STREAMTYPE_VCD; goto play; #endif #ifdef CONFIG_DVDREAD case ivSetDVDSubtitle: dvdsub_id = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDAudio: audio_id = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDChapter: guiInfo.Chapter = iparam; uiEvent(ivPlayDVD, 0); break; case ivSetDVDTitle: guiInfo.Track = iparam; guiInfo.Chapter = 1; guiInfo.Angle = 1; uiEvent(ivPlayDVD, 0); break; case evPlayDVD: guiInfo.Chapter = 1; guiInfo.Angle = 1; case ivPlayDVD: guiInfo.StreamType = STREAMTYPE_DVD; goto play; #endif #ifdef CONFIG_TV case evPlayTV: guiInfo.StreamType = guiTV[gui_tv_digital].StreamType; goto play; #endif case evPlay: case evPlaySwitchToPause: play: if (guiInfo.Playing != GUI_PAUSE) { MediumPrepare(guiInfo.StreamType); switch (guiInfo.StreamType) { case STREAMTYPE_FILE: case STREAMTYPE_STREAM: case STREAMTYPE_PLAYLIST: if (!guiInfo.Track) guiInfo.Track = 1; guiInfo.MediumChanged = GUI_MEDIUM_NEW; guiInfo.PlaylistNext = !guiInfo.Playing; break; case STREAMTYPE_CDDA: case STREAMTYPE_VCD: case STREAMTYPE_DVD: case STREAMTYPE_TV: case STREAMTYPE_DVB: if (!guiInfo.Track) guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); case STREAMTYPE_BINCUE: // track 0 is OK and will auto-select first media data track guiInfo.MediumChanged = GUI_MEDIUM_SAME; break; } } uiPlay(); break; case evPause: case evPauseSwitchToPlay: uiPause(); break; case evStop: guiInfo.Playing = GUI_STOP; uiState(); break; case evLoadPlay: uiLoadPlay = True; // guiInfo.StreamType=STREAMTYPE_FILE; case evLoad: gtkShow(evLoad, NULL); break; case evLoadSubtitle: gtkShow(evLoadSubtitle, NULL); break; case evDropSubtitle: nfree(guiInfo.SubtitleFilename); mplayerLoadSubtitle(NULL); break; case evLoadAudioFile: gtkShow(evLoadAudioFile, NULL); break; case evPlayImage: gtkShow(evPlayImage, NULL); break; case evPrev: uiPrev(); break; case evNext: uiNext(); break; case evPlaylist: gtkShow(evPlaylist, NULL); break; case evSkinBrowser: gtkShow(evSkinBrowser, skinName); break; case evAbout: gtkShow(evAbout, NULL); break; case evPreferences: gtkShow(evPreferences, NULL); break; case evEqualizer: gtkShow(evEqualizer, NULL); break; case evForward10min: uiRelSeek(600); break; case evBackward10min: uiRelSeek(-600); break; case evForward1min: uiRelSeek(60); break; case evBackward1min: uiRelSeek(-60); break; case evForward10sec: uiRelSeek(10); break; case evBackward10sec: uiRelSeek(-10); break; case evSetMoviePosition: guiInfo.Position = param; uiPctSeek(guiInfo.Position); break; case evIncVolume: mplayer_put_key(KEY_VOLUME_UP); break; case evDecVolume: mplayer_put_key(KEY_VOLUME_DOWN); break; case evMute: mixer_mute(mixer); break; case evSetVolume: case ivSetVolume: guiInfo.Volume = param; { float l = guiInfo.Volume * (100.0 - guiInfo.Balance) / 50.0; float r = guiInfo.Volume * guiInfo.Balance / 50.0; mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); } if (ev == ivSetVolume) break; if (osd_level) { osd_visible = (GetTimerMS() + 1000) | 1; vo_osd_progbar_type = OSD_VOLUME; vo_osd_progbar_value = guiInfo.Volume * 256.0 / 100.0; vo_osd_changed(OSDTYPE_PROGBAR); } break; case evSetBalance: case ivSetBalance: guiInfo.Balance = param; mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 uiEvent(ivSetVolume, guiInfo.Volume); if (ev == ivSetBalance) break; if (osd_level) { osd_visible = (GetTimerMS() + 1000) | 1; vo_osd_progbar_type = OSD_BALANCE; vo_osd_progbar_value = guiInfo.Balance * 256.0 / 100.0; vo_osd_changed(OSDTYPE_PROGBAR); } break; case evMenu: /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse * { pointer and cursor keys work * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as * uiMenuShow( 0,0 ); they do with normal menus. * } * else*/gtkShow(ivShowPopUpMenu, NULL); break; case evIconify: switch (iparam) { case 0: wsWindowIconify(&guiApp.mainWindow); break; case 1: wsWindowIconify(&guiApp.videoWindow); break; } break; case evHalfSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); btnSet(evFullScreen, btnReleased); } break; case evDoubleSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); btnSet(evFullScreen, btnReleased); } break; case evNormalSize: if (guiInfo.VideoWindow && guiInfo.Playing) { if (guiApp.videoWindow.isFullScreen) { uiFullScreen(); } wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); btnSet(evFullScreen, btnReleased); break; } else if (!guiApp.videoWindow.isFullScreen) break; case evFullScreen: if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { uiFullScreen(); if (!guiApp.videoWindow.isFullScreen) wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); } if (guiApp.videoWindow.isFullScreen) btnSet(evFullScreen, btnPressed); else btnSet(evFullScreen, btnReleased); break; case evSetAspect: switch (iparam) { case 2: aspect = 16.0f / 9.0f; break; case 3: aspect = 4.0f / 3.0f; break; case 4: aspect = 2.35f; break; case 1: default: aspect = -1; break; } snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect); mp_input_queue_cmd(mp_input_parse_cmd(cmd)); break; case evSetRotation: switch (iparam) { case 90: guiInfo.Rotation = 1; break; case -90: guiInfo.Rotation = 2; break; case 180: guiInfo.Rotation = 8; break; case 0: default: guiInfo.Rotation = -1; break; } guiInfo.MediumChanged = GUI_MEDIUM_SAME; break; /* timer events */ case ivRedraw: { unsigned int now = GetTimerMS(); if ((now > last_redraw_time) && (now < last_redraw_time + GUI_REDRAW_WAIT) && !uiPlaybarFade && (iparam == 0)) break; last_redraw_time = now; } uiMainRender = True; wsWindowRedraw(&guiApp.mainWindow); wsWindowRedraw(&guiApp.playbarWindow); break; /* system events */ case evNone: mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); break; default: mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); break; } }
/** * @brief Switch to next playback track. */ void uiNext(void) { int stop = False, unset = True; plItem *next = NULL; if (guiInfo.Playing == GUI_PAUSE) return; switch (guiInfo.StreamType) { case STREAMTYPE_CDDA: case STREAMTYPE_VCD: case STREAMTYPE_BINCUE: if (++guiInfo.Track > guiInfo.Tracks) { guiInfo.Track = guiInfo.Tracks; stop = True; } break; case STREAMTYPE_DVD: if (guiInfo.Chapter++ >= guiInfo.Chapters) { guiInfo.Chapter = 1; if (++guiInfo.Track > guiInfo.Tracks) { guiInfo.Track = guiInfo.Tracks; guiInfo.Chapter = guiInfo.Chapters; stop = True; } } else unset = False; break; case STREAMTYPE_TV: case STREAMTYPE_DVB: if (guiInfo.Playing == GUI_PLAY) mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel 1")); return; default: next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); if (next) { uiSetFileFromPlaylist(next); guiInfo.PlaylistNext = !guiInfo.Playing; break; } return; } if (stop) uiEvent(evStop, 0); if (guiInfo.Playing == GUI_PLAY) uiEvent(evPlay, 0); else if (!stop && !next && unset) uiUnsetMedia(True); }
/** * @brief Switch to previous playback track. */ void uiPrev(void) { int stop = False, unset = True; plItem *prev = NULL; if (guiInfo.Playing == GUI_PAUSE) return; switch (guiInfo.StreamType) { case STREAMTYPE_CDDA: if (--guiInfo.Track == 0) { guiInfo.Track = 1; stop = True; } break; case STREAMTYPE_VCD: if (--guiInfo.Track == 1) { guiInfo.Track = 2; stop = True; } break; case STREAMTYPE_DVD: if (--guiInfo.Chapter == 0) { guiInfo.Chapter = 1; if (--guiInfo.Track == 0) { guiInfo.Track = 1; stop = True; } } else unset = False; break; case STREAMTYPE_TV: case STREAMTYPE_DVB: if (guiInfo.Playing == GUI_PLAY) mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel -1")); return; case STREAMTYPE_BINCUE: if (--guiInfo.Track == 0) { guiInfo.Track = 1 + guiInfo.Angles; stop = True; } break; default: prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); if (prev) { uiSetFileFromPlaylist(prev); guiInfo.PlaylistNext = !guiInfo.Playing; break; } return; } if (stop) uiEvent(evStop, 0); if (guiInfo.Playing == GUI_PLAY) uiEvent(evPlay, 0); else if (!stop && !prev && unset) uiUnsetMedia(True); }