2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
int mplParent = 1;
|
|
|
|
|
2001-08-30 10:55:17 +00:00
|
|
|
int moviex,moviey,moviewidth,movieheight;
|
2001-08-28 15:55:02 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
#include "../app.h"
|
|
|
|
|
|
|
|
#include "../wm/ws.h"
|
|
|
|
#include "../wm/wskeys.h"
|
|
|
|
#include "../wm/widget.h"
|
|
|
|
|
|
|
|
#include "../../config.h"
|
2001-09-12 15:08:53 +00:00
|
|
|
#include "../../help_mp.h"
|
2001-08-27 23:56:44 +00:00
|
|
|
#include "../../libvo/x11_common.h"
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
#include "widgets.h"
|
|
|
|
#include "./mplayer.h"
|
|
|
|
#include "psignal.h"
|
|
|
|
#include "play.h"
|
|
|
|
|
2001-08-31 12:59:04 +00:00
|
|
|
#include "../skin/skin.h"
|
|
|
|
#include "../error.h"
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
mplCommStruct * mplShMem;
|
|
|
|
char * Filename = NULL;
|
|
|
|
|
2001-08-27 23:56:44 +00:00
|
|
|
extern float rel_seek_secs;
|
|
|
|
extern int abs_seek_pos;
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
void mplFullScreen( void )
|
|
|
|
{
|
2001-10-01 12:28:39 +00:00
|
|
|
static int sx,sy;
|
2001-11-18 19:19:57 +00:00
|
|
|
|
2001-10-01 12:28:39 +00:00
|
|
|
wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow );
|
|
|
|
if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,sx,sy );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
2001-10-01 12:28:39 +00:00
|
|
|
wsWindowDecoration( &appMPlayer.subWindow,appMPlayer.subWindow.Decorations );
|
|
|
|
appMPlayer.subWindow.isFullScreen=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sx=appMPlayer.subWindow.Width; sy=appMPlayer.subWindow.Height;
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,wsMaxX,wsMaxY );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.subWindow,True,0,0 );
|
2001-10-01 12:28:39 +00:00
|
|
|
wsWindowDecoration( &appMPlayer.subWindow,0 );
|
|
|
|
appMPlayer.subWindow.isFullScreen=1;
|
|
|
|
}
|
2001-10-02 15:01:56 +00:00
|
|
|
if ( mplShMem->Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
|
|
|
|
else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB );
|
2001-10-01 12:28:39 +00:00
|
|
|
wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow );
|
2001-08-29 17:48:06 +00:00
|
|
|
mplResize( 0,0,appMPlayer.subWindow.Width,appMPlayer.subWindow.Height );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int mplSubRender;
|
|
|
|
|
|
|
|
void mplStop()
|
|
|
|
{
|
|
|
|
mplShMem->Playing=0;
|
2001-08-31 21:19:52 +00:00
|
|
|
mplShMem->TimeSec=0;
|
2001-09-01 18:39:46 +00:00
|
|
|
mplShMem->Position=0;
|
2001-09-12 22:12:05 +00:00
|
|
|
mplShMem->AudioType=0;
|
2001-09-25 15:13:58 +00:00
|
|
|
// if ( !mplShMem->Playing ) return;
|
2001-08-31 10:30:57 +00:00
|
|
|
if ( !appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
2001-08-31 10:30:57 +00:00
|
|
|
}
|
2001-08-31 11:26:14 +00:00
|
|
|
mplSubRender=1;
|
2001-09-25 15:13:58 +00:00
|
|
|
wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB );
|
2001-10-02 15:01:56 +00:00
|
|
|
wsClearWindow( appMPlayer.subWindow );
|
2001-08-31 11:26:14 +00:00
|
|
|
wsPostRedisplay( &appMPlayer.subWindow );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplPlay( void )
|
|
|
|
{
|
2001-08-31 21:19:52 +00:00
|
|
|
if ( ( mplShMem->Filename[0] == 0 )||
|
2001-08-31 18:46:45 +00:00
|
|
|
( mplShMem->Playing == 1 ) ) return;
|
|
|
|
if ( mplShMem->Playing == 2 ) { mplPause(); return; }
|
2001-08-25 21:04:29 +00:00
|
|
|
mplShMem->Playing=1;
|
2001-08-30 22:07:19 +00:00
|
|
|
mplSubRender=0;
|
2001-09-05 18:17:22 +00:00
|
|
|
wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
|
|
|
|
wsClearWindow( appMPlayer.subWindow );
|
2001-09-04 15:21:00 +00:00
|
|
|
wsPostRedisplay( &appMPlayer.subWindow );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplPause( void )
|
|
|
|
{
|
2001-08-31 18:46:45 +00:00
|
|
|
switch( mplShMem->Playing )
|
|
|
|
{
|
|
|
|
case 1: // playing
|
|
|
|
mplShMem->Playing=2;
|
|
|
|
btnModify( evPlaySwitchToPause,btnReleased );
|
|
|
|
btnModify( evPauseSwitchToPlay,btnDisabled );
|
|
|
|
break;
|
|
|
|
case 2: // paused
|
|
|
|
mplShMem->Playing=1;
|
|
|
|
btnModify( evPlaySwitchToPause,btnDisabled );
|
|
|
|
btnModify( evPauseSwitchToPlay,btnReleased );
|
|
|
|
break;
|
|
|
|
}
|
2001-08-31 22:07:53 +00:00
|
|
|
mplSubRender=0;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height )
|
|
|
|
{
|
2001-09-04 15:21:00 +00:00
|
|
|
// printf( "----resize---> %dx%d --- \n",width,height );
|
2001-08-30 12:17:12 +00:00
|
|
|
vo_setwindowsize( width,height );
|
|
|
|
vo_resize=1;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplMPlayerInit( int argc,char* argv[], char *envp[] )
|
|
|
|
{
|
2001-09-03 16:13:25 +00:00
|
|
|
struct sigaction sa;
|
|
|
|
|
2001-09-01 18:39:46 +00:00
|
|
|
mplShMem=calloc( 1,sizeof( mplCommStruct ) );
|
2001-08-25 21:04:29 +00:00
|
|
|
mplShMem->Balance=50.0f;
|
2001-10-24 10:58:18 +00:00
|
|
|
mplShMem->StreamType=-1;
|
2001-09-03 16:13:25 +00:00
|
|
|
memset(&sa, 0, sizeof(sa));
|
|
|
|
sa.sa_handler = mplMainSigHandler;
|
|
|
|
sigaction( SIGTYPE,&sa,NULL );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float mplGetPosition( void )
|
|
|
|
{ // return 0.0 ... 100.0
|
2001-08-28 15:55:02 +00:00
|
|
|
return mplShMem->Position;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplRelSeek( float s )
|
|
|
|
{ // -+s
|
2001-08-27 23:56:44 +00:00
|
|
|
rel_seek_secs=s; abs_seek_pos=0;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mplAbsSeek( float s )
|
|
|
|
{ // 0.0 ... 100.0
|
2001-08-27 23:56:44 +00:00
|
|
|
rel_seek_secs=0.01*s; abs_seek_pos=3;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2001-08-31 12:59:04 +00:00
|
|
|
listItems tmpList;
|
|
|
|
|
|
|
|
void ChangeSkin( void )
|
|
|
|
{
|
2001-09-17 21:16:00 +00:00
|
|
|
int ret;
|
|
|
|
if ( !strcmp( skinName,gtkShMem->sb.name ) ) return;
|
2001-08-31 12:59:04 +00:00
|
|
|
#ifdef DEBUG
|
2001-09-17 21:16:00 +00:00
|
|
|
dbprintf( 1,"[psignal] skin: %s\n",gtkShMem->sb.name );
|
2001-08-31 12:59:04 +00:00
|
|
|
#endif
|
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
mainVisible=0;
|
2001-08-31 12:59:04 +00:00
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
appInitStruct( &tmpList );
|
|
|
|
skinAppMPlayer=&tmpList;
|
|
|
|
fntFreeFont();
|
|
|
|
ret=skinRead( gtkShMem->sb.name );
|
2001-08-31 12:59:04 +00:00
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
appInitStruct( &tmpList );
|
|
|
|
skinAppMPlayer=&appMPlayer;
|
|
|
|
appInitStruct( &appMPlayer );
|
|
|
|
if ( !ret ) strcpy( skinName,gtkShMem->sb.name );
|
|
|
|
skinRead( skinName );
|
|
|
|
if ( ret )
|
|
|
|
{
|
|
|
|
mainVisible=1;
|
|
|
|
return;
|
|
|
|
}
|
2001-09-01 19:57:44 +00:00
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
if ( appMPlayer.menuBase.Bitmap.Image )
|
|
|
|
{
|
|
|
|
if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer );
|
|
|
|
if ( ( mplMenuDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{ message( False,MSGTR_NEMDB ); return; }
|
|
|
|
wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
|
|
|
wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
|
|
|
}
|
2001-08-31 12:59:04 +00:00
|
|
|
|
2001-10-16 21:23:59 +00:00
|
|
|
if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height );
|
|
|
|
if ( ( !appMPlayer.subWindow.isFullScreen )&&( !mplShMem->Playing ) )
|
|
|
|
{
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
2001-10-16 21:23:59 +00:00
|
|
|
}
|
|
|
|
if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize );
|
|
|
|
if ( !mplShMem->Playing )
|
|
|
|
{
|
|
|
|
mplSubRender=1;
|
2001-11-14 23:47:08 +00:00
|
|
|
wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB );
|
2001-10-16 21:23:59 +00:00
|
|
|
wsClearWindow( appMPlayer.subWindow );
|
|
|
|
wsPostRedisplay( &appMPlayer.subWindow );
|
|
|
|
}
|
2001-08-31 12:59:04 +00:00
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
if ( mplDrawBuffer ) free( mplDrawBuffer );
|
|
|
|
if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{ message( False,MSGTR_NEMDB ); return; }
|
|
|
|
wsVisibleWindow( &appMPlayer.mainWindow,wsHideWindow );
|
|
|
|
wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.mainWindow,True,appMPlayer.main.x,appMPlayer.main.y );
|
2001-09-17 21:16:00 +00:00
|
|
|
wsResizeImage( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height );
|
|
|
|
wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );
|
|
|
|
wsWindowDecoration( &appMPlayer.mainWindow,appMPlayer.mainDecoration );
|
2001-11-18 19:19:57 +00:00
|
|
|
mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow );
|
2001-09-17 21:16:00 +00:00
|
|
|
wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow );
|
2001-09-07 21:04:14 +00:00
|
|
|
|
2001-09-17 21:16:00 +00:00
|
|
|
btnModify( evSetVolume,mplShMem->Volume );
|
|
|
|
btnModify( evSetBalance,mplShMem->Balance );
|
|
|
|
btnModify( evSetMoviePosition,mplShMem->Position );
|
2001-08-31 14:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventHandling( void )
|
|
|
|
{
|
2001-09-06 13:59:05 +00:00
|
|
|
wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
|
2001-09-17 21:16:00 +00:00
|
|
|
if ( mplShMem->SkinChange ) { ChangeSkin(); mplShMem->SkinChange=0; }
|
2001-08-31 12:59:04 +00:00
|
|
|
}
|
2001-09-25 14:00:19 +00:00
|
|
|
|
|
|
|
void mplResizeToMovieSize( unsigned int width,unsigned int height )
|
|
|
|
{
|
|
|
|
if ( !appMPlayer.subWindow.isFullScreen )
|
2001-10-01 09:30:46 +00:00
|
|
|
{
|
2001-09-25 14:00:19 +00:00
|
|
|
wsResizeWindow( &appMPlayer.subWindow,width,height );
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
2001-10-01 09:30:46 +00:00
|
|
|
}
|
2001-09-25 14:00:19 +00:00
|
|
|
}
|
2001-11-12 15:16:13 +00:00
|
|
|
|
|
|
|
void mplSetFileName( char * fname )
|
|
|
|
{
|
|
|
|
if ( ( fname )&&( gtkShMem ) ) strcpy( gtkShMem->fs.filename,fname );
|
|
|
|
}
|