📄 mw.c
字号:
// main window#include <stdlib.h>#include <stdio.h>#include <inttypes.h>#include <sys/stat.h>#include <unistd.h>#include <string.h>#include "gmplayer.h"#include "app.h"#include "skin/font.h"#include "skin/skin.h"#include "wm/ws.h"#include "../config.h"#include "../help_mp.h"#include "../libvo/x11_common.h"#include "../libvo/fastmemcpy.h"#include "../stream/stream.h"#include "../stream/url.h"#include "../mixer.h"#include "../libvo/sub.h"#include "../access_mpcontext.h"#include "../libmpdemux/demuxer.h"#include "../libmpdemux/stheader.h"#include "../codec-cfg.h"#include "../m_option.h"#include "../m_property.h"#define GUI_REDRAW_WAIT 375#include "play.h"#include "widgets.h"extern unsigned int GetTimerMS( void );unsigned char * mplDrawBuffer = NULL;int mplMainRender = 1;int mplMainAutoPlay = 0;int mplMiddleMenu = 0;int mainVisible = 1;int boxMoved = 0;int sx = 0,sy = 0;int i,pot = 0;#include "common.h"void mplMainDraw( void ){ if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( MSGTR_Exit_quit ); if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible || !mainVisible ) return;// !appMPlayer.mainWindow.Mapped ) return; if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose ) { btnModify( evSetMoviePosition,guiIntfStruct.Position ); btnModify( evSetVolume,guiIntfStruct.Volume ); fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize ); Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); mplMainRender=0; } wsPutImage( &appMPlayer.mainWindow );// XFlush( wsDisplay );}static unsigned last_redraw_time = 0;void mplEventHandling( int msg,float param ){ int iparam = (int)param; mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); switch( msg ) {// --- user events case evExit: exit_player( "Exit" ); break; case evPlayNetwork: gfree( (void **)&guiIntfStruct.Subtitlename ); gfree( (void **)&guiIntfStruct.AudioFile ); guiIntfStruct.StreamType=STREAMTYPE_STREAM; goto play; case evSetURL: gtkShow( evPlayNetwork,NULL ); break; case evSetAudio: if ( !guiIntfStruct.demuxer || audio_id == iparam ) break; audio_id=iparam; goto play; case evSetVideo: if ( !guiIntfStruct.demuxer || video_id == iparam ) break; video_id=iparam; goto play; case evSetSubtitle: mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext); break;#ifdef HAVE_VCD case evSetVCDTrack: guiIntfStruct.Track=iparam; case evPlayVCD: gtkSet( gtkClearStruct,0,(void *)guiALL ); guiIntfStruct.StreamType=STREAMTYPE_VCD; goto play;#endif#ifdef USE_DVDREAD case evPlayDVD: guiIntfStruct.DVD.current_title=1; guiIntfStruct.DVD.current_chapter=1; guiIntfStruct.DVD.current_angle=1;play_dvd_2: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) ); guiIntfStruct.StreamType=STREAMTYPE_DVD; goto play;#endif case evPlay: case evPlaySwitchToPause:play: if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause; if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) ) { plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL ); plLastPlayed=next; mplSetFileName( next->path,next->name,STREAMTYPE_FILE ); } switch ( guiIntfStruct.StreamType ) { case STREAMTYPE_STREAM: case STREAMTYPE_FILE: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) ); break;#ifdef HAVE_VCD case STREAMTYPE_VCD: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) ); if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE ); mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD ); if ( guiIntfStruct.Playing != 2 ) { if ( !guiIntfStruct.Track ) { if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2; else guiIntfStruct.Track=1; } guiIntfStruct.DiskChanged=1; } break;#endif#ifdef USE_DVDREAD case STREAMTYPE_DVD: gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); if ( guiIntfStruct.Playing != 2 ) { guiIntfStruct.Title=guiIntfStruct.DVD.current_title; guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; guiIntfStruct.DiskChanged=1; } break;#endif } guiIntfStruct.NewPlay=1; mplPlay(); break;#ifdef USE_DVDREAD case evSetDVDSubtitle: dvdsub_id=iparam; goto play_dvd_2; break; case evSetDVDAudio: audio_id=iparam; goto play_dvd_2; break; case evSetDVDChapter: guiIntfStruct.DVD.current_chapter=iparam; goto play_dvd_2; break; case evSetDVDTitle: guiIntfStruct.DVD.current_title=iparam; guiIntfStruct.DVD.current_chapter=1; guiIntfStruct.DVD.current_angle=1; goto play_dvd_2; break;#endif case evPause: case evPauseSwitchToPlay:NoPause: mplPause(); break; case evStop: guiIntfStruct.Playing=guiSetStop; mplState(); guiIntfStruct.NoWindow=False; break; case evLoadPlay: mplMainAutoPlay=1;// guiIntfStruct.StreamType=STREAMTYPE_FILE; case evLoad: gtkSet( gtkDelPl,0,NULL ); gtkShow( evLoad,NULL ); break; case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; case evDropSubtitle: gfree( (void **)&guiIntfStruct.Subtitlename ); guiLoadSubtitle( NULL ); break; case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; case evPrev: mplPrev(); break; case evNext: mplNext(); 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: mplRelSeek( 600 ); break; case evBackward10min: mplRelSeek( -600 );break; case evForward1min: mplRelSeek( 60 ); break; case evBackward1min: mplRelSeek( -60 ); break; case evForward10sec: mplRelSeek( 10 ); break; case evBackward10sec: mplRelSeek( -10 ); break; case evSetMoviePosition: mplAbsSeek( param ); break; case evIncVolume: vo_x11_putkey( wsGrayMul ); break; case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; case evMute: mixer_mute( mixer ); break; case evSetVolume: guiIntfStruct.Volume=param; goto set_volume; case evSetBalance: guiIntfStruct.Balance=param;set_volume: { float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume;// printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); mixer_setvolume( mixer,l,r ); } if ( osd_level ) { osd_visible=(GetTimerMS() + 1000) | 1; vo_osd_progbar_type=OSD_VOLUME; vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; vo_osd_changed( OSDTYPE_PROGBAR ); } break; case evIconify: switch ( iparam ) { case 0: wsIconify( appMPlayer.mainWindow ); break; case 1: wsIconify( appMPlayer.subWindow ); break; } break; case evHalfSize: btnSet( evFullScreen,btnReleased ); if ( guiIntfStruct.Playing ) { if ( appMPlayer.subWindow.isFullScreen ) { mplFullScreen(); } wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); wsMoveWindow( &appMPlayer.subWindow, 0, ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); } break; case evDoubleSize: btnSet( evFullScreen,btnReleased ); if ( guiIntfStruct.Playing ) { if ( appMPlayer.subWindow.isFullScreen ) { mplFullScreen(); } wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); wsMoveWindow( &appMPlayer.subWindow, 0, ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); } break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -