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-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 "../config.h"
|
|
|
|
#include "../error.h"
|
|
|
|
#include "../language.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-08-30 10:55:17 +00:00
|
|
|
// if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
// {
|
|
|
|
// }
|
|
|
|
wsFullScreen( &appMPlayer.subWindow );
|
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()
|
|
|
|
{
|
|
|
|
if ( !mplShMem->Playing ) return;
|
|
|
|
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-08-31 10:30:57 +00:00
|
|
|
if ( !appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
wsMoveWindow( &appMPlayer.subWindow,appMPlayer.sub.x,appMPlayer.sub.y );
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
|
|
|
}
|
2001-08-31 11:26:14 +00:00
|
|
|
mplSubRender=1;
|
|
|
|
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-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 )
|
|
|
|
{
|
|
|
|
if ( strcmp( cfgSkin,gtkShMem->sb.name ) )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
#ifdef DEBUG
|
|
|
|
dbprintf( 1,"[psignal] skin: %s\n",gtkShMem->sb.name );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mainVisible=0;
|
|
|
|
|
|
|
|
appInitStruct( &tmpList );
|
|
|
|
skinAppMPlayer=&tmpList;
|
|
|
|
ret=skinRead( gtkShMem->sb.name );
|
|
|
|
|
2001-09-01 19:57:44 +00:00
|
|
|
fntFreeFont();
|
|
|
|
|
2001-08-31 12:59:04 +00:00
|
|
|
appInitStruct( &tmpList );
|
|
|
|
skinAppMPlayer=&appMPlayer;
|
|
|
|
appInitStruct( &appMPlayer );
|
|
|
|
if ( !ret ) strcpy( cfgSkin,gtkShMem->sb.name );
|
|
|
|
skinRead( cfgSkin );
|
|
|
|
|
|
|
|
if ( ret )
|
|
|
|
{
|
|
|
|
mainVisible=1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// appCopy( &appMPlayer,&tmpList );
|
|
|
|
// appInitStruct( &tmpList );
|
|
|
|
// skinAppMPlayer=&appMPlayer;
|
|
|
|
// strcpy( cfgSkin,gtkShMem->sb.name );
|
|
|
|
|
|
|
|
if ( mplDrawBuffer ) free( mplDrawBuffer );
|
|
|
|
if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{ message( False,langNEMDB ); return; }
|
|
|
|
wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height );
|
|
|
|
wsMoveWindow( &appMPlayer.mainWindow,appMPlayer.main.x,appMPlayer.main.y );
|
2001-09-05 18:17:22 +00:00
|
|
|
wsResizeImage( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height );
|
2001-08-31 12:59:04 +00:00
|
|
|
wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );
|
|
|
|
mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow );
|
2001-09-05 18:17:22 +00:00
|
|
|
|
2001-08-31 12:59:04 +00:00
|
|
|
btnModify( evSetVolume,mplShMem->Volume );
|
|
|
|
btnModify( evSetBalance,mplShMem->Balance );
|
|
|
|
btnModify( evSetMoviePosition,mplShMem->Position );
|
|
|
|
|
|
|
|
if ( appMPlayer.menuBase.Bitmap.Image )
|
|
|
|
{
|
|
|
|
if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer );
|
|
|
|
if ( ( mplMenuDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{ message( False,langNEMDB ); return; }
|
|
|
|
wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
2001-09-05 18:17:22 +00:00
|
|
|
wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
2001-08-31 12:59:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mplSkinChanged=1;
|
2001-09-05 18:17:22 +00:00
|
|
|
if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height );
|
2001-08-31 12:59:04 +00:00
|
|
|
if ( !mplShMem->Playing )
|
|
|
|
{
|
|
|
|
mplSkinChanged=0;
|
2001-09-05 18:17:22 +00:00
|
|
|
// if ( appMPlayer.subWindow.isFullScreen ) wsFullScreen( &appMPlayer.subWindow );
|
|
|
|
if ( !appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
|
|
|
wsMoveWindow( &appMPlayer.subWindow,appMPlayer.sub.x,appMPlayer.sub.y );
|
|
|
|
}
|
|
|
|
wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB );
|
|
|
|
wsClearWindow( appMPlayer.subWindow );
|
2001-08-31 12:59:04 +00:00
|
|
|
mplSubRender=1; wsPostRedisplay( &appMPlayer.subWindow );
|
|
|
|
}
|
|
|
|
}
|
2001-08-31 14:16:28 +00:00
|
|
|
mplShMem->SkinChange=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventHandling( void )
|
|
|
|
{
|
2001-09-06 13:59:05 +00:00
|
|
|
wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
|
2001-08-31 14:16:28 +00:00
|
|
|
if ( mplShMem->SkinChange ) ChangeSkin();
|
2001-08-31 12:59:04 +00:00
|
|
|
}
|