Mercurial > mplayer.hg
annotate Gui/mplayer/play.c @ 4830:2c1dd0b15622
reworked :) should work on low bpp outputs
author | alex |
---|---|
date | Sun, 24 Feb 2002 02:21:14 +0000 |
parents | 3473ca9ef158 |
children | 13262bd21965 |
rev | line source |
---|---|
4428 | 1 #include <inttypes.h> |
1693 | 2 #include <stdlib.h> |
3 #include <stdio.h> | |
4 | |
5 #include <unistd.h> | |
6 #include <signal.h> | |
7 | |
8 #include "../wm/ws.h" | |
9 #include "../../config.h" | |
1884 | 10 #include "../../help_mp.h" |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
11 #include "../../libvo/x11_common.h" |
1693 | 12 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
13 #include "../app.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 #include "../wm/wskeys.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "../wm/widget.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
17 #include "../interface.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
18 |
1693 | 19 #include "widgets.h" |
20 #include "./mplayer.h" | |
21 #include "play.h" | |
22 | |
1800 | 23 #include "../skin/skin.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
24 #include "../skin/font.h" |
1693 | 25 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
26 extern float rel_seek_secs; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
27 extern int abs_seek_pos; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
28 |
1693 | 29 void mplFullScreen( void ) |
30 { | |
2029 | 31 static int sx,sy; |
2979 | 32 |
2029 | 33 wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); |
34 if ( appMPlayer.subWindow.isFullScreen ) | |
35 { | |
36 wsResizeWindow( &appMPlayer.subWindow,sx,sy ); | |
2854 | 37 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
2029 | 38 wsWindowDecoration( &appMPlayer.subWindow,appMPlayer.subWindow.Decorations ); |
39 appMPlayer.subWindow.isFullScreen=0; | |
40 } | |
41 else | |
42 { | |
43 sx=appMPlayer.subWindow.Width; sy=appMPlayer.subWindow.Height; | |
44 wsResizeWindow( &appMPlayer.subWindow,wsMaxX,wsMaxY ); | |
2854 | 45 wsMoveWindow( &appMPlayer.subWindow,True,0,0 ); |
2029 | 46 wsWindowDecoration( &appMPlayer.subWindow,0 ); |
47 appMPlayer.subWindow.isFullScreen=1; | |
48 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
49 if ( guiIntfStruct.Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
2045 | 50 else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
2029 | 51 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); |
1756 | 52 mplResize( 0,0,appMPlayer.subWindow.Width,appMPlayer.subWindow.Height ); |
1693 | 53 } |
54 | |
55 extern int mplSubRender; | |
56 | |
57 void mplStop() | |
58 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
59 guiIntfStruct.Playing=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
60 guiIntfStruct.TimeSec=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
61 guiIntfStruct.Position=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
62 guiIntfStruct.AudioType=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
63 // if ( !guiIntfStruct.Playing ) return; |
1796 | 64 if ( !appMPlayer.subWindow.isFullScreen ) |
65 { | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
66 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); |
2854 | 67 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
1796 | 68 } |
1797 | 69 mplSubRender=1; |
2045 | 70 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
1953 | 71 wsClearWindow( appMPlayer.subWindow ); |
1797 | 72 wsPostRedisplay( &appMPlayer.subWindow ); |
1693 | 73 } |
74 | |
75 void mplPlay( void ) | |
76 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
77 if ( ( !guiIntfStruct.Filename )|| |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
78 ( guiIntfStruct.Filename[0] == 0 )|| |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
79 ( guiIntfStruct.Playing == 1 ) ) return; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
80 if ( guiIntfStruct.Playing == 2 ) { mplPause(); return; } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
81 guiIntfStruct.Playing=1; |
1791 | 82 mplSubRender=0; |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
83 wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
84 wsClearWindow( appMPlayer.subWindow ); |
1852 | 85 wsPostRedisplay( &appMPlayer.subWindow ); |
1693 | 86 } |
87 | |
88 void mplPause( void ) | |
89 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
90 switch( guiIntfStruct.Playing ) |
1804 | 91 { |
92 case 1: // playing | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
93 guiIntfStruct.Playing=2; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
94 // btnModify( evPlaySwitchToPause,btnReleased ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
95 // btnModify( evPauseSwitchToPlay,btnDisabled ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
96 break; |
4465 | 97 case 2: // paused |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
98 guiIntfStruct.Playing=1; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
99 // btnModify( evPlaySwitchToPause,btnDisabled ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
100 // btnModify( evPauseSwitchToPlay,btnReleased ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
101 break; |
1804 | 102 } |
4465 | 103 mplState(); |
1815 | 104 mplSubRender=0; |
1693 | 105 } |
106 | |
4465 | 107 void mplState( void ) |
108 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
109 if ( ( guiIntfStruct.Playing == 0 )||( guiIntfStruct.Playing == 2 ) ) |
4465 | 110 { |
111 btnModify( evPlaySwitchToPause,btnReleased ); | |
112 btnModify( evPauseSwitchToPlay,btnDisabled ); | |
113 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
114 else |
4465 | 115 { |
116 btnModify( evPlaySwitchToPause,btnDisabled ); | |
117 btnModify( evPauseSwitchToPlay,btnReleased ); | |
118 } | |
119 } | |
120 | |
1693 | 121 void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height ) |
122 { | |
123 } | |
124 | |
125 void mplMPlayerInit( int argc,char* argv[], char *envp[] ) | |
126 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
127 guiIntfStruct.Balance=50.0f; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
128 guiIntfStruct.StreamType=-1; |
1693 | 129 } |
130 | |
131 float mplGetPosition( void ) | |
132 { // return 0.0 ... 100.0 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
133 return guiIntfStruct.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 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
148 void ChangeSkin( char * name ) |
1800 | 149 { |
1907 | 150 int ret; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
151 // if ( !strcmp( skinName,name ) ) return; |
1907 | 152 mainVisible=0; |
1800 | 153 |
1907 | 154 appInitStruct( &tmpList ); |
155 skinAppMPlayer=&tmpList; | |
156 fntFreeFont(); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
157 ret=skinRead( name ); |
1800 | 158 |
1907 | 159 appInitStruct( &tmpList ); |
160 skinAppMPlayer=&appMPlayer; | |
161 appInitStruct( &appMPlayer ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
162 if ( ret ) name=skinName; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
163 if ( skinRead( name ) ) |
1907 | 164 { |
165 mainVisible=1; | |
166 return; | |
167 } | |
1800 | 168 |
1907 | 169 if ( appMPlayer.menuBase.Bitmap.Image ) |
170 { | |
171 if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer ); | |
172 if ( ( mplMenuDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
173 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; } |
1907 | 174 wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); |
175 wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); | |
176 } | |
1800 | 177 |
2226 | 178 if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
179 if ( ( !appMPlayer.subWindow.isFullScreen )&&( !guiIntfStruct.Playing ) ) |
2226 | 180 { |
181 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); | |
2854 | 182 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
183 } |
2226 | 184 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
185 if ( !guiIntfStruct.Playing ) |
2226 | 186 { |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
187 mplSubRender=1; |
2911 | 188 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
2226 | 189 wsClearWindow( appMPlayer.subWindow ); |
190 wsPostRedisplay( &appMPlayer.subWindow ); | |
191 } | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1861
diff
changeset
|
192 |
1907 | 193 if ( mplDrawBuffer ) free( mplDrawBuffer ); |
194 if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
195 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; } |
1907 | 196 wsVisibleWindow( &appMPlayer.mainWindow,wsHideWindow ); |
197 wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); | |
2854 | 198 wsMoveWindow( &appMPlayer.mainWindow,True,appMPlayer.main.x,appMPlayer.main.y ); |
1907 | 199 wsResizeImage( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); |
200 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
2979 | 201 wsWindowDecoration( &appMPlayer.mainWindow,appMPlayer.mainDecoration ); |
1907 | 202 mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); |
203 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
204 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
205 btnModify( evSetVolume,guiIntfStruct.Volume ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
206 btnModify( evSetBalance,guiIntfStruct.Balance ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
207 btnModify( evSetMoviePosition,guiIntfStruct.Position ); |
3479 | 208 btnModify( evFullScreen,!appMPlayer.subWindow.isFullScreen ); |
1800 | 209 } |
1802 | 210 |
1952 | 211 void mplResizeToMovieSize( unsigned int width,unsigned int height ) |
212 { | |
213 if ( !appMPlayer.subWindow.isFullScreen ) | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
214 { |
1952 | 215 wsResizeWindow( &appMPlayer.subWindow,width,height ); |
2854 | 216 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
217 } |
1952 | 218 } |
2854 | 219 |
220 void mplSetFileName( char * fname ) | |
221 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
222 if ( !fname ) return; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
223 if ( guiIntfStruct.Filename ) free( guiIntfStruct.Filename ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
224 guiIntfStruct.Filename=strdup( fname ); |
2854 | 225 } |