library sample_sub;

uses
  Windows,
  bspplg in '..\..\bspplg.pas',
  bsp in '..\..\..\bsp.pas';

var pInfo:PpluginInfo;


procedure Config(const winh:HWND);
begin
  Messagebox(winh,'Configuration','Info',0);
end;

function loadSubtitles(const subName:Pchar):integer;
var subID:integer;
begin
  //You would parse subtitle(subName) file here
  //but for example we will just add a few lines

  //Create new subtitles
  subID:=pInfo.createSubs('English subtitles');

  //Add new line that will start at 5 sec and last to 12 sec
  pInfo.addLine(subID,5000,12000,'This is subtitle from 5 to 12 sec');

  //Add few more lines
  pInfo.addLine(subID,15000,17000,'<b>This is subtitle from 15 to 17 sec bold</b>');
  pInfo.addLine(subID,20000,24000,'This is subtitle from 20 to 24 sec\nLine 2');

  //pInfo.activateSubs(subID);

  Result:=0; //All OK

end;

function CallbackProc(const cmdID:DWORD;param1,param2:pointer):integer;stdcall;
begin
  case cmdID of
    EV_CONFIG:Config(HWND(param1));
    EV_ABOUT:Messagebox(HWND(param1),'Sample subtitle plugin v 0.1','About',0);
    EV_LOAD_SUB:Result:=loadSubtitles(pchar(param1));
  end;
end;

function pluginInit(plgInfo: PpluginInfo): BOOL; stdcall;
begin
  plgInfo.description:='Sample subtitle plugin';
  plgInfo.plgCallback:=CallbackProc;

  pInfo:=plgInfo;
  pinfo.subRegisterExt('*.bssub');
  result:=true;
end;

exports pluginInit;

begin
end.
 