[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Пример XM, MOD, S3M плеера на PHP 5
I++
В данном примере используется расширение PHP WinBinder, а так же библиотека bass.dll

user posted image

<?[SPAN=darling]php[/SPAN]

/*================================================================================
[INIT]
=================================================================================*/


if(wb_get_instance(APPNAME, TRUE))
die;

include "include/winbinder.php";

define("APPNAME", "PHP Player"); // The window title will be seen in the taskbar and on Alt+tab
define("WIDTH", 400);
define("HEIGHT", 300);

define("MUSIC_FILE", './music/russian_vodka.xm');

define("BASS_MUSIC_LOOP", 4);

# Load BASS library
$BASS_LIB = wb_load_library("./bass.dll");

# Init functions
$BASS_Init = wb_get_function_address("BASS_Init", $BASS_LIB);
$BASS_MusicLoad = wb_get_function_address("BASS_MusicLoad", $BASS_LIB);
$BASS_ChannelPlay = wb_get_function_address("BASS_ChannelPlay", $BASS_LIB);

# Init BASS library
if (!wb_call_function($BASS_Init, array(-1, 44100, 0, 0, null)))
{
wb_message_box(NULL, 'Can\'t initiate a connection to the BASS dll');
exit;
}

# Load music file
if (!$stream = wb_call_function($BASS_MusicLoad, array(false, MUSIC_FILE, 0, 0, 0, 4, 0)))
{
wb_message_box(NULL, "Can't load $file");
exit;
}

/*================================================================================
[Resource load]
=================================================================================*/


$GLOBALS['images'][0] = wb_load_image('./res/top.bmp');
$GLOBALS['images'][1] = wb_load_image('./res/button.bmp');

/*================================================================================
[MAIN]
=================================================================================*/

# Create window

$mainwin = wb_create_window(NULL, NakedWindow, APPNAME, WBC_CENTER, WBC_CENTER, WIDTH, HEIGHT, WBC_INVISIBLE | WBC_NOTIFY | WBC_CUSTOMDRAW, WBC_REDRAW);

# Set top area
wb_set_area($mainwin, WBC_TITLE, 0, 0, WIDTH, 50);

# Create close button
$btn = wb_create_control($mainwin, ImageButton, false, 125, 125, 150, 50, IDCLOSE, WBC_IMAGE);
wb_set_image($btn, $GLOBALS['images'][1]);
wb_destroy_image($btn);

# Play music
wb_call_function($BASS_ChannelPlay, array($stream, false));

wb_set_handler($mainwin, "process_main");
wb_set_image($mainwin, './res/blue_pirates.ico');
wb_set_visible($mainwin, TRUE);

wb_main_loop();

function process_main($window, $id, $ctrl, $lparam1=0, $lparam2=0)
{
switch($id)
{
case IDDEFAULT:

if($lparam1 & WBC_REDRAW)
{
$winsize = wb_get_size($window, true);

// Draw background and top
wb_draw_rect($lparam2, 0, 0, $winsize[0], $winsize[1], 0x1E1E1E);
wb_draw_image($lparam2, $GLOBALS['images'][0], 0, 0);
}

break;

case IDCLOSE:
wb_destroy_window($window);
break;
}
}


?>


Готовый пример можно скачать тут: СКАЧАТЬ

Все работает и запускается из коробки.
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.