Mercurial > mplayer.hg
annotate Gui/mplayer/play.c @ 5689:2077782d0ca9
add prev/next title feature for gui dvd support
author | pontscho |
---|---|
date | Thu, 18 Apr 2002 18:24:08 +0000 |
parents | 3e7f39c4110c |
children | 436cf6ef67fd |
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" |
5665 | 12 #include "../../input/input.h" |
1693 | 13 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 #include "../app.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "../wm/wskeys.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
17 #include "../wm/widget.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
18 #include "../interface.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
19 |
1693 | 20 #include "widgets.h" |
21 #include "./mplayer.h" | |
22 #include "play.h" | |
23 | |
1800 | 24 #include "../skin/skin.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
25 #include "../skin/font.h" |
1693 | 26 |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
27 extern float rel_seek_secs; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
28 extern int abs_seek_pos; |
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
29 |
1693 | 30 void mplFullScreen( void ) |
31 { | |
2029 | 32 static int sx,sy; |
2979 | 33 |
5032 | 34 // if ( !guiIntfStruct.Playing ) |
2029 | 35 { |
4981 | 36 wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); |
37 if ( appMPlayer.subWindow.isFullScreen ) | |
38 { | |
39 wsResizeWindow( &appMPlayer.subWindow,sx,sy ); | |
40 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
41 wsWindowDecoration( &appMPlayer.subWindow,appMPlayer.subWindow.Decorations ); | |
42 appMPlayer.subWindow.isFullScreen=0; | |
43 } | |
44 else | |
45 { | |
46 sx=appMPlayer.subWindow.Width; sy=appMPlayer.subWindow.Height; | |
47 wsResizeWindow( &appMPlayer.subWindow,wsMaxX,wsMaxY ); | |
48 wsMoveWindow( &appMPlayer.subWindow,True,0,0 ); | |
49 wsWindowDecoration( &appMPlayer.subWindow,0 ); | |
50 appMPlayer.subWindow.isFullScreen=1; | |
51 } | |
5032 | 52 vo_fs=appMPlayer.subWindow.isFullScreen; |
4981 | 53 wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); |
5032 | 54 }// else { vo_x11_fullscreen(); appMPlayer.subWindow.isFullScreen=vo_fs; } |
4981 | 55 |
56 fullscreen=appMPlayer.subWindow.isFullScreen; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
57 if ( guiIntfStruct.Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
2045 | 58 else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
1693 | 59 } |
60 | |
61 extern int mplSubRender; | |
62 | |
63 void mplStop() | |
64 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
65 guiIntfStruct.Playing=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
66 guiIntfStruct.TimeSec=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
67 guiIntfStruct.Position=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
68 guiIntfStruct.AudioType=0; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
69 // if ( !guiIntfStruct.Playing ) return; |
1796 | 70 if ( !appMPlayer.subWindow.isFullScreen ) |
71 { | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
72 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); |
2854 | 73 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); |
1796 | 74 } |
5689 | 75 guiGetEvent( guiCEvent,guiSetStop ); |
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 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
84 if ( ( !guiIntfStruct.Filename )|| |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
85 ( guiIntfStruct.Filename[0] == 0 )|| |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
86 ( guiIntfStruct.Playing == 1 ) ) return; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
87 if ( guiIntfStruct.Playing == 2 ) { mplPause(); return; } |
4963 | 88 guiGetEvent( guiCEvent,guiSetPlay ); |
1791 | 89 mplSubRender=0; |
1858
88a88d0a3f94
fix skin changing, xv fullscreen redraw bug, etc.
pontscho
parents:
1852
diff
changeset
|
90 wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
91 wsClearWindow( appMPlayer.subWindow ); |
4963 | 92 // wsPostRedisplay( &appMPlayer.subWindow ); |
1693 | 93 } |
94 | |
95 void mplPause( void ) | |
96 { | |
5665 | 97 mp_cmd_t * cmd = (mp_cmd_t *)calloc( 1,sizeof( *cmd ) ); |
98 cmd->id=MP_CMD_PAUSE; | |
99 cmd->name=strdup("pause"); | |
100 mp_input_queue_cmd(cmd); | |
1815 | 101 mplSubRender=0; |
1693 | 102 } |
103 | |
4465 | 104 void mplState( void ) |
105 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
106 if ( ( guiIntfStruct.Playing == 0 )||( guiIntfStruct.Playing == 2 ) ) |
4465 | 107 { |
108 btnModify( evPlaySwitchToPause,btnReleased ); | |
109 btnModify( evPauseSwitchToPlay,btnDisabled ); | |
110 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
111 else |
4465 | 112 { |
113 btnModify( evPlaySwitchToPause,btnDisabled ); | |
114 btnModify( evPauseSwitchToPlay,btnReleased ); | |
115 } | |
116 } | |
117 | |
1693 | 118 void mplMPlayerInit( int argc,char* argv[], char *envp[] ) |
119 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
120 guiIntfStruct.Balance=50.0f; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
121 guiIntfStruct.StreamType=-1; |
1693 | 122 } |
123 | |
124 float mplGetPosition( void ) | |
125 { // return 0.0 ... 100.0 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
126 return guiIntfStruct.Position; |
1693 | 127 } |
128 | |
129 void mplRelSeek( float s ) | |
130 { // -+s | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
131 rel_seek_secs=s; abs_seek_pos=0; |
1693 | 132 } |
133 | |
134 void mplAbsSeek( float s ) | |
135 { // 0.0 ... 100.0 | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1693
diff
changeset
|
136 rel_seek_secs=0.01*s; abs_seek_pos=3; |
1693 | 137 } |
138 | |
1800 | 139 listItems tmpList; |
140 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
141 void ChangeSkin( char * name ) |
1800 | 142 { |
1907 | 143 int ret; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
144 // if ( !strcmp( skinName,name ) ) return; |
1907 | 145 mainVisible=0; |
1800 | 146 |
1907 | 147 appInitStruct( &tmpList ); |
148 skinAppMPlayer=&tmpList; | |
149 fntFreeFont(); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
150 ret=skinRead( name ); |
1800 | 151 |
1907 | 152 appInitStruct( &tmpList ); |
153 skinAppMPlayer=&appMPlayer; | |
154 appInitStruct( &appMPlayer ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
155 if ( ret ) name=skinName; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
156 if ( skinRead( name ) ) |
1907 | 157 { |
158 mainVisible=1; | |
159 return; | |
160 } | |
1800 | 161 |
1907 | 162 if ( appMPlayer.menuBase.Bitmap.Image ) |
163 { | |
164 if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer ); | |
165 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
|
166 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; } |
1907 | 167 wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); |
168 wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height ); | |
169 } | |
1800 | 170 |
2226 | 171 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
|
172 if ( ( !appMPlayer.subWindow.isFullScreen )&&( !guiIntfStruct.Playing ) ) |
2226 | 173 { |
174 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height ); | |
2854 | 175 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
|
176 } |
2226 | 177 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
|
178 if ( !guiIntfStruct.Playing ) |
2226 | 179 { |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
180 mplSubRender=1; |
2911 | 181 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB ); |
2226 | 182 wsClearWindow( appMPlayer.subWindow ); |
183 wsPostRedisplay( &appMPlayer.subWindow ); | |
184 } | |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1861
diff
changeset
|
185 |
1907 | 186 if ( mplDrawBuffer ) free( mplDrawBuffer ); |
187 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
|
188 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; } |
1907 | 189 wsVisibleWindow( &appMPlayer.mainWindow,wsHideWindow ); |
190 wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); | |
2854 | 191 wsMoveWindow( &appMPlayer.mainWindow,True,appMPlayer.main.x,appMPlayer.main.y ); |
1907 | 192 wsResizeImage( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height ); |
193 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image ); | |
2979 | 194 wsWindowDecoration( &appMPlayer.mainWindow,appMPlayer.mainDecoration ); |
1907 | 195 mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); |
196 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
197 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
198 btnModify( evSetVolume,guiIntfStruct.Volume ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
199 btnModify( evSetBalance,guiIntfStruct.Balance ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
200 btnModify( evSetMoviePosition,guiIntfStruct.Position ); |
3479 | 201 btnModify( evFullScreen,!appMPlayer.subWindow.isFullScreen ); |
1800 | 202 } |
1802 | 203 |
1952 | 204 void mplResizeToMovieSize( unsigned int width,unsigned int height ) |
205 { | |
206 if ( !appMPlayer.subWindow.isFullScreen ) | |
2025
0653e90b3118
some bug fix, and sub window render speed up.. 10l kola ? :)
pontscho
parents:
1953
diff
changeset
|
207 { |
1952 | 208 wsResizeWindow( &appMPlayer.subWindow,width,height ); |
2854 | 209 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
|
210 } |
1952 | 211 } |
2854 | 212 |
213 void mplSetFileName( char * fname ) | |
214 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
215 if ( !fname ) return; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
216 if ( guiIntfStruct.Filename ) free( guiIntfStruct.Filename ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
217 guiIntfStruct.Filename=strdup( fname ); |
2854 | 218 } |
5689 | 219 |
220 void mplPrev( void ) | |
221 { | |
222 int stop = 0; | |
223 switch ( guiIntfStruct.StreamType ) | |
224 { | |
225 // case STREAMTYPE_FILE: | |
226 case STREAMTYPE_DVD: | |
227 if ( guiIntfStruct.Playing == 2 ) break; | |
228 if ( --guiIntfStruct.DVD.current_chapter == 0 ) | |
229 { | |
230 guiIntfStruct.DVD.current_chapter=1; | |
231 if ( --guiIntfStruct.DVD.current_title <= 0 ) { guiIntfStruct.DVD.current_title=1; stop=1; } | |
232 } | |
233 guiIntfStruct.Track=guiIntfStruct.DVD.current_title; | |
234 if ( stop ) mplEventHandling( evStop,0 ); | |
235 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 ); | |
236 break; | |
237 } | |
238 } | |
239 | |
240 void mplNext( void ) | |
241 { | |
242 int stop = 0; | |
243 switch ( guiIntfStruct.StreamType ) | |
244 { | |
245 // case STREAMTYPE_FILE: | |
246 case STREAMTYPE_DVD: | |
247 if ( guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters ) | |
248 { | |
249 guiIntfStruct.DVD.current_chapter=1; | |
250 if ( ++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles ) { guiIntfStruct.DVD.current_title=guiIntfStruct.DVD.titles; stop=1; } | |
251 } | |
252 guiIntfStruct.Track=guiIntfStruct.DVD.current_title; | |
253 if ( stop ) mplEventHandling( evStop,0 ); | |
254 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 ); | |
255 break; | |
256 } | |
257 } |