Pictures will only appear when the paint event is called, so that you may use timer to schedule the playing sequence as below. I use media player classic, you may use other players. Did the color swapped by |."1 ?

NB. =========================================================
require 'bmp gl2'
coinsert 'jgl2'

STUDY=: 0 : 0
pc study;
xywh 0 0 32 30;cc P1 button;cn "1";
xywh 33 0 32 30;cc P2 button;cn "2";
xywh 66 0 32 30;cc P3 button;cn "3";
xywh 0 33 300 300;cc g isigraph;
pas 0 0;
rem form end;
)

study_run=: 3 : 0
wd STUDY
wd 'pshow;ptop;'
imgfn=: '' [ tick=: 0
wd 'setfocus P1;'
NB. uncomment for autorun
NB. study_P1_button ''
)

study_close=: 3 : 0
wd 'timer 0;pclose'
)

study_P1_button=: 3 :0
wd 'timer 100' [ tick=: 0 [ button=: 1
paint '~system\examples\data\toucan.bmp'
wd 'winexec *"c:\mpc\mplayerc.exe" -play -close -minimized "c:\song\assorted\anthem.mp3"'
)

study_P2_button=: 3 : 0
wd 'timer 100' [ tick=: 0 [ button=: 2
paint '~system\examples\data\jbox.bmp'
wd 'winexec *"c:\mpc\mplayerc.exe" -play -close -minimized "c:\song\assorted\china.mp3"'
)

study_P3_button=: 3 : 0
wd 'timer 100' [ tick=: 0 [ button=: 3
paint '~system\examples\data\j.bmp'
wd 'winexec *"c:\mpc\mplayerc.exe" -play -close -minimized "c:\song\assorted\anthem.mp3"'
)

paint=: 3 : 0
glclear_jgl2_ ''
if. ''-:y do. return. end.
NB. dat=. 256 #. |."1 [ 256 256 256 #: readbmp jpath y
dat=. 256 #. 256 256 256 #: readbmp jpath y
glpixels_jgl2_ (0 33,|.$dat),,dat
glpaint_jgl2_ ''
)

sys_timer=: 3 : 0
if. interval <: tick=: >:tick do.
  wd 'timer 0'
  tick=: 0
  select. button
  case. 1 do. study_P2_button '' [ wd 'setfocus P2'
  case. 2 do. study_P3_button '' [ wd 'setfocus P3'
  case. 3 do. study_P1_button '' [ wd 'setfocus P1'
  end.
end.
)

interval=: 100  NB. interval in 0.1s
study_run ''
NB. =========================================================

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to