Mercurial > mplayer.hg
annotate Gui/mplayer/play.c @ 4155:7c0b4665668d
by koth
author | gabucino |
---|---|
date | Mon, 14 Jan 2002 23:06:43 +0000 |
parents | 2704448de713 |
children | 3e1378354c2e |
rev | line source |
---|---|
1693 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 | |
5 #include <unistd.h> | |
6 #include <signal.h> | |
7 | |
8 int mplParent = 1; | |
9 | |
1765 | 10 int moviex,moviey,moviewidth,movieheight; |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
11 |
1693 | 12 #include "../app.h" |
13 | |
14 #include "../wm/ws.h" | |
15 #include "../wm/wskeys.h" | |
16 #include "../wm/widget.h" | |
17 | |
18 #include "../../config.h" | |
1884 | 19 #include "../../help_mp.h" |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
20 #include "../../libvo/x11_common.h" |
1693 | 21 |
22 #include "widgets.h" | |
23 #include "./mplayer.h" | |
24 #include "psignal.h" | |
25 #include "play.h" | |
26 | |
1800 | 27 #include "../skin/skin.h" |
28 #include "../error.h" | |
29 | |
1693 | 30 mplCommStruct * mplShMem; |
31 char * Filename = NULL; | |
32 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
33 extern float rel_seek_secs; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
34 extern int abs_seek_pos; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
35 |
1693 | 36 void mplFullScreen( void ) |
37 { | |
2029 | 38 static int sx,sy; |
2979 | 39 |
2029 | 40 wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); |
41 if ( appMPlayer.subWindow.isFullScreen ) | |
42 { | |
43 wsResizeWindow( &appMPlayer.subWindow,sx,sy ); | |
2854 | 44 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
2029 | 45 wsWindowDecoration( &appMPlayer.subWindow,appMPlayer.subWindow.Decorations ); |
46 appMPlayer.subWindow.isFullScreen=0; | |
47 } | |
48 else | |
49 { | |
50 sx=appMPlayer.subWindow.Width; sy=appMPlayer.subWindow.Height; | |
51 wsResizeWindow( &appMPlayer.subWindow,wsMaxX,wsMaxY ); | |
2854 | 52 wsMoveWindow( &appMPlayer.subWindow,True,0,0 ); |
2029 | 53 wsWindowDecoration( &appMPlayer.subWindow,0 ); |
54 appMPlayer.subWindow.isFullScreen=1; | |
55 } | |
2045 | 56 if ( mplShMem->Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
57 else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); | |
2029 | 58 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); |
1756 | 59 mplResize( 0,0,appMPlayer.subWindow.Width,appMPlayer.subWindow.Height ); |
1693 | 60 } |
61 | |
62 extern int mplSubRender; | |
63 | |
64 void mplStop() | |
65 { | |
66 mplShMem->Playing=0; | |
1812 | 67 mplShMem->TimeSec=0; |
1825 | 68 mplShMem->Position=0; |
1888 | 69 mplShMem->AudioType=0; |
1953 | 70 // if ( !mplShMem->Playing ) return; |
1796 | 71 if ( !appMPlayer.subWindow.isFullScreen ) |
72 { | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
73 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); |
2854 | 74 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
1796 | 75 } |
1797 | 76 mplSubRender=1; |
2045 | 77 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
1953 | 78 wsClearWindow( appMPlayer.subWindow ); |
1797 | 79 wsPostRedisplay( &appMPlayer.subWindow ); |
1693 | 80 } |
81 | |
82 void mplPlay( void ) | |
83 { | |
1812 | 84 if ( ( mplShMem->Filename[0] == 0 )|| |
1804 | 85 ( mplShMem->Playing == 1 ) ) return; |
86 if ( mplShMem->Playing == 2 ) { mplPause(); return; } | |
1693 | 87 mplShMem->Playing=1; |
1791 | 88 mplSubRender=0; |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
89 wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
90 wsClearWindow( appMPlayer.subWindow ); |
1852 | 91 wsPostRedisplay( &appMPlayer.subWindow ); |
1693 | 92 } |
93 | |
94 void mplPause( void ) | |
95 { | |
1804 | 96 switch( mplShMem->Playing ) |
97 { | |
98 case 1: // playing | |
99 mplShMem->Playing=2; | |
100 btnModify( evPlaySwitchToPause,btnReleased ); | |
101 btnModify( evPauseSwitchToPlay,btnDisabled ); | |
102 break; | |
103 case 2: // paused | |
104 mplShMem->Playing=1; | |
105 btnModify( evPlaySwitchToPause,btnDisabled ); | |
106 btnModify( evPauseSwitchToPlay,btnReleased ); | |
107 break; | |
108 } | |
1815 | 109 mplSubRender=0; |
1693 | 110 } |
111 | |
112 void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height ) | |
113 { | |
1852 | 114 // printf( "----resize---> %dx%d --- \n",width,height ); |
1770 | 115 vo_setwindowsize( width,height ); |
116 vo_resize=1; | |
1693 | 117 } |
118 | |
119 void mplMPlayerInit( int argc,char* argv[], char *envp[] ) | |
120 { | |
1850 | 121 struct sigaction sa; |
122 | |
1825 | 123 mplShMem=calloc( 1,sizeof( mplCommStruct ) ); |
124 mplShMem->Balance=50.0f; | |
2447 | 125 mplShMem->StreamType=-1; |
1850 | 126 memset(&sa, 0, sizeof(sa)); |
127 sa.sa_handler = mplMainSigHandler; | |
128 sigaction( SIGTYPE,&sa,NULL ); | |
1693 | 129 } |
130 | |
131 float mplGetPosition( void ) | |
132 { // return 0.0 ... 100.0 | |
1729 | 133 return mplShMem->Position; |
1693 | 134 } |
135 | |
136 void mplRelSeek( float s ) | |
137 { // -+s | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
138 rel_seek_secs=s; abs_seek_pos=0; |
1693 | 139 } |
140 | |
141 void mplAbsSeek( float s ) | |
142 { // 0.0 ... 100.0 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
143 rel_seek_secs=0.01*s; abs_seek_pos=3; |
1693 | 144 } |
145 | |
1800 | 146 listItems tmpList; |
147 | |
148 void ChangeSkin( void ) | |
149 { | |
1907 | 150 int ret; |
151 if ( !strcmp( skinName,gtkShMem->sb.name ) ) return; | |
1800 | 152 #ifdef DEBUG |
1907 | 153 dbprintf( 1,"[psignal] skin: %s\n",gtkShMem->sb.name ); |
1800 | 154 #endif |
155 | |
1907 | 156 mainVisible=0; |
1800 | 157 |
1907 | 158 appInitStruct( &tmpList ); |
159 skinAppMPlayer=&tmpList; | |
160 fntFreeFont(); | |
161 ret=skinRead( gtkShMem->sb.name ); | |
1800 | 162 |
1907 | 163 appInitStruct( &tmpList ); |
164 skinAppMPlayer=&appMPlayer; | |
165 appInitStruct( &appMPlayer ); | |
166 if ( !ret ) strcpy( skinName,gtkShMem->sb.name ); | |
167 skinRead( skinName ); | |
168 if ( ret ) | |
169 { | |
170 mainVisible=1; | |
171 return; | |
172 } | |
1800 | 173 |
1907 | 174 if ( appMPlayer.menuBase.Bitmap.Image ) |
175 { | |
176 if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer ); | |
177 if ( ( mplMenuDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL ) | |
178 { message( False,MSGTR_NEMDB ); return; } | |
179 wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); | |
180 wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); | |
181 } | |
1800 | 182 |
2226 | 183 if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height ); |
184 if ( ( !appMPlayer.subWindow.isFullScreen )&&( !mplShMem->Playing ) ) | |
185 { | |
186 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); | |
2854 | 187 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
2226 | 188 } |
189 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); | |
190 if ( !mplShMem->Playing ) | |
191 { | |
192 mplSubRender=1; | |
2911 | 193 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
2226 | 194 wsClearWindow( appMPlayer.subWindow ); |
195 wsPostRedisplay( &appMPlayer.subWindow ); | |
196 } | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1861
diff
changeset
|
197 |
1907 | 198 if ( mplDrawBuffer ) free( mplDrawBuffer ); |
199 if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) | |
200 { message( False,MSGTR_NEMDB ); return; } | |
201 wsVisibleWindow( &appMPlayer.mainWindow,wsHideWindow ); | |
202 wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); | |
2854 | 203 wsMoveWindow( &appMPlayer.mainWindow,True,appMPlayer.main.x,appMPlayer.main.y ); |
1907 | 204 wsResizeImage( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); |
205 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
2979 | 206 wsWindowDecoration( &appMPlayer.mainWindow,appMPlayer.mainDecoration ); |
1907 | 207 mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); |
208 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1861
diff
changeset
|
209 |
1907 | 210 btnModify( evSetVolume,mplShMem->Volume ); |
211 btnModify( evSetBalance,mplShMem->Balance ); | |
212 btnModify( evSetMoviePosition,mplShMem->Position ); | |
3479 | 213 btnModify( evFullScreen,!appMPlayer.subWindow.isFullScreen ); |
1800 | 214 } |
1802 | 215 |
216 void EventHandling( void ) | |
217 { | |
1861 | 218 wsHandleEvents();mplTimerHandler(0); // handle GUI timer events |
1907 | 219 if ( mplShMem->SkinChange ) { ChangeSkin(); mplShMem->SkinChange=0; } |
1802 | 220 } |
1952 | 221 |
222 void mplResizeToMovieSize( unsigned int width,unsigned int height ) | |
223 { | |
224 if ( !appMPlayer.subWindow.isFullScreen ) | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
225 { |
1952 | 226 wsResizeWindow( &appMPlayer.subWindow,width,height ); |
2854 | 227 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
228 } |
1952 | 229 } |
2854 | 230 |
231 void mplSetFileName( char * fname ) | |
232 { | |
233 if ( ( fname )&&( gtkShMem ) ) strcpy( gtkShMem->fs.filename,fname ); | |
234 } |