forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Open Source]: Media Player
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Sep 07, 2003 3:01 pm    Post subject: Reply with quote

I've changed a lot of things here:

Code:
  option DECIMALSEP,"."
  option errortrap,error
  title Media Player
  dialog CREATE,Media Player,-1,0,515,155,COLOR BLACK
  dialog ADD,STYLE,LINK,Verdana,,U,,WHITE
  dialog ADD,STYLE,SMALL,Verdana,,,,FFFF80
  dialog ADD,STYLE,LARGE,Verdana,24,,,FFFF80
  dialog ADD,BITMAP,gui,-1,-1,516,155,gui.bmp,,CLICK
  dialog ADD,TEXT,TIME,18,24,,,00:00,,TRANSPARENT,LARGE
  dialog ADD,TEXT,length,64,24,,,,,TRANSPARENT,SMALL
  dialog ADD,TEXT,SONG,10,236,264,13,Click the @chr(34)eject@chr(34) button to load a song...,,TRANSPARENT,SMALL
  dialog ADD,TEXT,SiteLink,140,278,,,Visit http://www.vdsworld.com!,,LINK,TRANSPARENT,CLICK,HAND
  dialog ADD,TEXT,b1,125,8,27,22,,,CLICK,HAND,TRANSPARENT
  dialog ADD,TEXT,b2,125,38,26,22,,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b3,125,66,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b4,125,94,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b5,125,122,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b6,125,156,30,22,,,HAND,CLICK,TRANSPARENT,DEFAULT
  dialog ADD,TRACKBAR,TRACKBAR1,87,8,202,22,0,,,CLICK,BOTH
  rem THIS BUTTON WAS ADDED TPO PREVENT UGLY FOCUS ON THE TACKBAR
  dialog ADD,BUTTON,DUMMY,0,0,0,0,0
  dialog SHOW
  dialog FOCUS,DUMMY
  %%paused = 1
:DUMMYbutton
:B5CLICK
:B1CLICK
:Evloop
  if %%play
    wait event,0.1
    else
      wait event
    end
    %e = @event()
    goto %e
:Timer
    if %%song
      %r = @mci(status sound length)
    end
    rem Prevent givng alpanumeric error messages to crash math functions
    if @numeric(%R)

      if %%Paused
        rem IF LENGTH OF sound IS CURENT POSITION SOUND HAS REACHED END  SO STOP IT
        if @equal(%I,%R)
          goto B4CLICK
        end
      end
    end
    if @not(@mousedown(L))
      %r = @mci(status sound length)
      %i = @mci(status sound position)
      if @numeric(%R)
        rem TRAP ZERO POSITION
        if @greater(%R,%I)
          %q = @fdiv(%I,%R)
          dialog SET,TRACKBAR1,@format(@fmul(@fdiv(%I,%R),100),4.0)
        end
      end
    end
if @not(@zero(%I))
    rem Convert to 00:00 Format
    %%songlength = @fdiv(%I,1000)
    %t = @format(%%SongLength,".0")
    %%secsinday = @prod(@prod(24,60),60)
    %%time = @fdiv(%T,%%SecsInDay)
    %%time = @datetime(nn:ss,%%Time)
    dialog SET,TIME,%%time
end
  end

  goto evloop
 
:guiCLICK
  if @equal(@click(b),RIGHT)
    dialog popup,Volume...|-|About Media Player
  end
  goto evloop
:Volume...MENU
  shell open,@windir(s)\sndvol32.exe
  goto evloop
:About Media PlayerMENU
  info Media Player 1.0@cr()@cr()An open source project at www.vdsworld.com@cr()@cr()Credits:@cr()@chr(32)- CodeScript for a lot of the MCI work and some API code used@cr()@chr(32)- FreezingFire for the idea/miscellaneous improvments/gui
  goto evloop
:B2CLICK
  rem Play
  if @not(%%song)
    %x = @event()
    goto evloop
  end
  if %%paused
    %%stop = @mci(close sound wait)
    %%play = @mci(open %%song alias sound wait)
    dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
    else
      dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
    end
    %%play = @mci(play sound)
    if %%play
      %%play = @mci(stop sound wait)
      %%play = @mci(play sound)
    end
    if %%play
      dialog SET,SONG,%%play
    end
    %%paused = 1
    %%play = 1
         rem Convert to 00:00 Format
    %r = @mci(status sound length)
    if @not(@zero(%R))
    %%songlength = @fdiv(%R,1000)
    %t = @format(%%SongLength,".0")
    %%secsinday = @prod(@prod(24,60),60)
    %%time = @fdiv(%T,%%SecsInDay)
    %%time = @datetime(nn:ss,%%Time)
    dialog set,length,Total Time %%time
    end
    goto evloop


:B3CLICK
    rem Pause
    if %%paused
      %a = @mci(pause sound)
    end
    %%paused = ""
    dialog SET,SONG,Paused
    wait 0.1
    rem This delay prevents a indeterminate condition in MCI device
    rem Increse the value if required
    goto evloop

:B4CLICK
    rem Stop
    %%stop = @mci(stop sound wait)
    dialog SET,SONG,Click the @chr(34)eject@chr(34) button to load a song...
    %%play = ""
    %%paused = 1
    rem Set The current position %I back to zero
    rem else it will not play again as stop event is fired!
    %i = 0
    dialog SET,TIME,00:00
    dialog SET,TRACKBAR1,0
    goto evloop
:B6CLICK
    rem Eject
    %%song1 = @filedlg("Known Media Files|*.wav;*.mp3;*.wma|Waveform Audio Files (*.wav)|*.wav|MP3 Files (*.mp3)|*.mp3|WMA Files (*.wma)|*.wma")
    %%song = @shortname(%%song1)
    if @ok()
      goto B2CLICK
    end
    %%song = ""
    goto evloop

:TRACKBAR1CLICK
    if @numeric(%R)
      %a = @mci(Seek sound to @format(@fmul(@fdiv(%R,100),@dlgtext(TRACKBAR1)),4.0))
      wait 0.3
      %a = @mci(play sound)
      dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
      else
        dialog SET,TRACKBAR1,0
      end
      wait 0.1
      dialog FOCUS,DUMMY
      %%paused = 1
      goto EVLOOP

:SiteLinkCLICK
      shell open,"http://www.vdsworld.com/"
      goto evloop
:Close
      %%stop = @mci(close sound)
      exit
:Error
option errortrap
DIALOG CREATE,Media Player,-1,0,299,154,NOMIN,COLOR BLACK,ONTOP,CLASS TMediaPlayerErrDlg
  DIALOG ADD,STYLE,NORMAL,Tahoma,,,,WHITE
  DIALOG ADD,STYLE,TITLE,Tahoma,12,B,,WHITE
  DIALOG ADD,BITMAP,STOP,15,17,32,32,#stop.bmp
  DIALOG ADD,TEXT,ErrorT,22,60,,,An Error Has Occurred,,TITLE
  DIALOG ADD,TEXT,TEXT1,60,17,,,Something went wrong and Media Player must close.@cr()It will be restarted after it closes.,,NORMAL
  DIALOG ADD,BUTTON,OK,110,112,64,24,OK
  if @greater(@sysinfo(dsver),5.0)@equal(@sysinfo(dsver),5.0)
  # Disable close button code by CodeScript #
    LOADLIB USER32.DLL
%H = @strdel(@WINEXISTS(#TMediaPlayerErrDlg),1,1)
 IF %H
      %I = @lib(user32,GetSystemMenu,INT:,%H, 0)
      %J = @lib(user32,GetMenuItemCount,INT:,%I)
      %K = @DIFF(%J,1)
      %L = @DIFF(%J,2)
      %M = @lib(user32,RemoveMenu,BOOL:,%I,%K,$400)
      %M = @lib(user32,RemoveMenu,BOOL:,%I,%L,$400)
      %M = @lib(user32,DrawMenuBar,BOOL:,%H)
          ELSE
   warn ERROR -1
  end
  FREELIB USER32.DLL
  end
  DIALOG SHOWMODAL
  shell open,%0
stop

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Sun Sep 07, 2003 3:11 pm    Post subject: Reply with quote

Well, when I run it, I can't see any of the controls. Question
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Sep 07, 2003 3:13 pm    Post subject: Reply with quote

You need to download the GUI (mentioned in the fist post) but I've put
together all of the files needed for this in a ZIP:

http://freezingfire.vdsworld.com/files/mplay.zip

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Sun Sep 07, 2003 3:14 pm    Post subject: Reply with quote

Yeah, Just saw that Rolling Eyes ...sorry Embarassed
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Sep 07, 2003 3:14 pm    Post subject: Reply with quote

No problem... I wouldn't have noticed that. Wink
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Sun Sep 07, 2003 3:19 pm    Post subject: Reply with quote

Works very nice!
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sun Sep 07, 2003 4:50 pm    Post subject: Reply with quote

FF I just tested your changed version of the script.
I have a few suggestions:

You added a fatal exit dialog for any error and forgot cleanup there Shocked
Even if you like to show fatal exit to the user at all ensure:
%%stop = @mci(close sound) before exit
If you ask me this kind of thing is really unessesary as the MCI interface in vdsruntime will handle
almost every MCI error to take necessary action. So if there is a error I would show a friendly message
in the song status area asking the user to retry once/something.
No need to restart the player.

I drove this modified code below against a text file indisguise as a mp3 and tried to crash it.
(I have just avoided giving nonnumeric values to math functions again in your newly added code)
No it doesnt crash the app at all. You can
open another real mp3 as if nothing had happened !!

Also now that you have chosen to use API you can use API to use multimedia hotkeys if U want.
Furhter if U are working on it seriously as a complete app then you should
reconsider the way the buttons are clicked.
It doesnot differentiate Rt,Lt or middle buttons. May be U use bitbtn or @CLICK().
You may be knowing that bitmap in VDS 5 supports mouseover!.

Also you can keep the player a tool window and still have a takbar icon using API.
Just a few suggestions.
Let me know what U feel.

Code:
  option DECIMALSEP,"."
  option errortrap,error
  title Media Player
  dialog CREATE,Media Player,-1,0,515,155,COLOR BLACK
  dialog ADD,STYLE,LINK,Verdana,,U,,WHITE
  dialog ADD,STYLE,SMALL,Verdana,,,,FFFF80
  dialog ADD,STYLE,LARGE,Verdana,24,,,FFFF80
  dialog ADD,BITMAP,gui,-1,-1,516,155,gui.bmp,,CLICK
  dialog ADD,TEXT,TIME,18,24,,,00:00,,TRANSPARENT,LARGE
  dialog ADD,TEXT,length,64,24,,,,,TRANSPARENT,SMALL
  dialog ADD,TEXT,SONG,10,236,264,13,Click the @chr(34)eject@chr(34) button to load a song...,,TRANSPARENT,SMALL
  dialog ADD,TEXT,SiteLink,140,278,,,Visit http://www.vdsworld.com!,,LINK,TRANSPARENT,CLICK,HAND
  dialog ADD,TEXT,b1,125,8,27,22,,,CLICK,HAND,TRANSPARENT
  dialog ADD,TEXT,b2,125,38,26,22,,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b3,125,66,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b4,125,94,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b5,125,122,26,22,,,HAND,CLICK,TRANSPARENT
  dialog ADD,TEXT,b6,125,156,30,22,,,HAND,CLICK,TRANSPARENT,DEFAULT
  dialog ADD,TRACKBAR,TRACKBAR1,87,8,202,22,0,,,CLICK,BOTH
  rem THIS BUTTON WAS ADDED TPO PREVENT UGLY FOCUS ON THE TACKBAR
  dialog ADD,BUTTON,DUMMY,0,0,0,0,0
  dialog SHOW
  dialog FOCUS,DUMMY
  %%paused = 1
:DUMMYbutton
:B5CLICK
:B1CLICK
:Evloop
  if %%play
    wait event,0.1
    else
      wait event
    end
    %e = @event()
    goto %e
:Timer
    if %%song
      %r = @mci(status sound length)
    end
    rem Prevent givng alpanumeric error messages to crash math functions
    if @numeric(%R)
      if %%Paused
        rem IF LENGTH OF sound IS CURENT POSITION SOUND HAS REACHED END SO STOP IT
        if @equal(%I,%R)
          goto B4CLICK
        end
      end
    end
    if @not(@mousedown(L))
      %r = @mci(status sound length)
      %i = @mci(status sound position)
      if @numeric(%R)
        rem TRAP ZERO POSITION
        if @greater(%R,%I)
          %q = @fdiv(%I,%R)
          dialog SET,TRACKBAR1,@format(@fmul(@fdiv(%I,%R),100),4.0)
        end
      end
     end 
     if @not(@zero(%I))
      IF @NUMERIC(%I)
      rem Convert to 00:00 Format
      %%songlength = @fdiv(%I,1000)
      %t = @format(%%SongLength,".0")
      %%secsinday = @prod(@prod(24,60),60)
      %%time = @fdiv(%T,%%SecsInDay)
      %%time = @datetime(nn:ss,%%Time)
      dialog SET,TIME,%%time
     end
   end
  end
 

  goto evloop

:guiCLICK
  if @equal(@click(b),RIGHT)
    dialog popup,Volume...|-|About Media Player
  end
  goto evloop
:Volume...MENU
  shell open,@windir(s)\sndvol32.exe
  goto evloop
:About Media PlayerMENU
  info Media Player 1.0@cr()@cr()An open source project at www.vdsworld.com@cr()@cr()Credits:@cr()@chr(32)- CodeScript for a lot of the MCI work and some API code used@cr()@chr(32)- FreezingFire for the idea/miscellaneous improvments/gui
  goto evloop
:B2CLICK
  rem Play
  if @not(%%song)
    %x = @event()
    goto evloop
  end
  if %%paused
    %%stop = @mci(close sound wait)
    %%play = @mci(open %%song alias sound wait)
    dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
    else
      dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
    end
    %%play = @mci(play sound)
    if %%play
      %%play = @mci(stop sound wait)
      %%play = @mci(play sound)
    end
    if %%play
      dialog SET,SONG,%%play
    end
    %%paused = 1
    %%play = 1
    REM Convert to 00:00 Format
    %r = @mci(status sound length)
    if @not(@zero(%R))
     if @numeric(%R)
      %%songlength = @fdiv(%R,1000)
      %t = @format(%%SongLength,".0")
      %%secsinday = @prod(@prod(24,60),60)
      %%time = @fdiv(%T,%%SecsInDay)
      %%time = @datetime(nn:ss,%%Time)
      dialog set,length,Total Time %%time
    end
     end
    goto evloop


:B3CLICK
    rem Pause
    if %%paused
      %a = @mci(pause sound)
    end
    %%paused = ""
    dialog SET,SONG,Paused
    wait 0.1
    rem This delay prevents a indeterminate condition in MCI device
    rem Increse the value if required
    goto evloop

:B4CLICK
    rem Stop
    %%stop = @mci(stop sound wait)
    dialog SET,SONG,Click the @chr(34)eject@chr(34) button to load a song...
    %%play = ""
    %%paused = 1
    rem Set The current position %I back to zero
    rem else it will not play again as stop event is fired!
    %i = 0
    dialog SET,TIME,00:00
    dialog set,length,Total Time,""
    dialog SET,TRACKBAR1,0
    goto evloop
:B6CLICK
    rem Eject
    %%song1 = @filedlg("Known Media Files|*.wav;*.mp3;*.wma|Waveform Audio Files (*.wav)|*.wav|MP3 Files (*.mp3)|*.mp3|WMA Files (*.wma)|*.wma")
    %%song = @shortname(%%song1)
    if @ok()
      goto B2CLICK
    end
    %%song = ""
    goto evloop

:TRACKBAR1CLICK
    if @numeric(%R)
      %a = @mci(Seek sound to @format(@fmul(@fdiv(%R,100),@dlgtext(TRACKBAR1)),4.0))
      wait 0.3
      %a = @mci(play sound)
      dialog SET,SONG,Playing @name(%%song1).@ext(%%song1)
      else
        dialog SET,TRACKBAR1,0
      end
      wait 0.1
      dialog FOCUS,DUMMY
      %%paused = 1
      goto EVLOOP

:SiteLinkCLICK
      shell open,"http://www.vdsworld.com/"
      goto evloop
:Close
      %%stop = @mci(close sound)
      exit
:Error
      option errortrap
      dialog CREATE,Media Player,-1,0,299,154,NOMIN,COLOR BLACK,ONTOP,CLASS TMediaPlayerErrDlg
      dialog ADD,STYLE,NORMAL,Tahoma,,,,WHITE
      dialog ADD,STYLE,TITLE,Tahoma,12,B,,WHITE
      dialog ADD,BITMAP,STOP,15,17,32,32,stop.bmp
      dialog ADD,TEXT,ErrorT,22,60,,,An Error Has Occurred,,TITLE
      dialog ADD,TEXT,TEXT1,60,17,,,Something went wrong and Media Player must close.@cr()It will be restarted after it closes.,,NORMAL
      dialog ADD,BUTTON,OK,110,112,64,24,OK
      if @greater(@sysinfo(dsver),5.0)@equal(@sysinfo(dsver),5.0)
        # Disable close button code by CodeScript #
        loadlib USER32.DLL
        %h = @strdel(@winexists(#TMediaPlayerErrDlg),1,1)
        if %H
          %i = @lib(user32,GetSystemMenu,INT:,%H, 0)
          %j = @lib(user32,GetMenuItemCount,INT:,%I)
          %k = @diff(%J,1)
          %l = @diff(%J,2)
          %m = @lib(user32,RemoveMenu,BOOL:,%I,%K,$400)
          %m = @lib(user32,RemoveMenu,BOOL:,%I,%L,$400)
          %m = @lib(user32,DrawMenuBar,BOOL:,%H)
          else
            warn ERROR -1
          end
          freelib USER32.DLL
        end
        dialog SHOWMODAL
        %%stop = @mci(close sound)
        shell open,%0
        stop

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group