April 26, 2024, 06:28:23 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Arono needs some help

Started by LarryMc, October 23, 2017, 07:33:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

From a PM to me
QuoteHi,

I am interested in playing video files (AVI or MP4 or MOV or WMV, whichever would be best) in IWBasic.  I looked at the winmcidemo program in the Help2 folder, compiled and ran it and it worked.

Now I would like to change the program to play a video file but I don't have a clue as to what to use in the mciSendStringA commands.

Can you help?

Thanks.
What kind of video file?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

October 24, 2017, 06:01:37 AM #1 Last Edit: October 24, 2017, 06:04:50 AM by Egil
Example below is converted from old IB code. I have tried it on mp3, wmv and mpg only, but should be able to play a lot of multimedia types, as long as their codecs are installed on your computer. The code need Fletchie's ctl.lib to  compile. (think it can be found somewhere on this forum, if not I can post it).


Good Luck!
Egil



' an example of using Windows MCI to play and control all sorts of media.
' created by Andrew
' http://www.pyxia.com/community/viewtopic.php?t=9856
' Compile as a WINDOWS target

' Needs Fletchie's ctl.lib (http://fletchie.pyxia.com/) as well as the API's from his site

DECLARE IMPORT, mciSendStringA(lpszCommand:STRING,lpszReturnString:POINTER,cchReturn:INT,hwndCallback:UINT),int
$include "ctl.inc"

DEF filename:STRING
DEF filter:STRING
DEF command,status:STRING
DEF fltTime:FLOAT
DEF min,sec,flag,i:INT

DEF w1:window
OPENWINDOW w1,0,0,350,200,@MINBOX,0,"Jukebox",&mainwindow
CONTROL w1,@BUTTON,"Play",20,120,100,20,0x50018001,11
CONTROL w1,@BUTTON,"Pause",125,120,100,20,0x50018001,12
CONTROL w1,@BUTTON,"Stop",230,120,100,20,0x50018001,13

BEGINMENU w1
   MENUTITLE "&File"
   MENUITEM "&Load Multimedia",0,1
   MENUITEM "&Play",0,4
   MENUITEM "&Stop Playback",0,3
   MENUITEM "&Quit",0,2
ENDMENU

conSliderControl(w1,10,15,100,320,16,"AF")
conSliderSetThumbSize(w1,10,12)


filter = "All files|*.*|Windows Media (*.wmv)|*.wmv|MPeg Video (*.mpg)|*.mpg|AVI Video (*.avi)|*.avi|MP3 files (*.mp3)|*.mp3|Midi files (*.mid)|*.mid|Wave Audio (*.wav)|*.wav||"
run = 1
WAITUNTIL run=0

command = "close mymidi"
mciSendStringA(command,NULL,0,0)
CLOSEWINDOW w1
END

SUB mainwindow(),INT
select @class
   CASE @IDCLOSEWINDOW
      run = 0
   CASE @IDMENUPICK
      SELECT @MENUNUM
         CASE 1
            filename = FILEREQUEST("Open media file",w1,1,filter)
            if(len(filename))
               SETCURSOR w1,@CSWAIT
               command = "close mymidi"
               mciSendStringA(command,NULL,0,0)
               command = "open \"" + filename + "\" alias mymidi"
               mciSendStringA(command,NULL,0,0)
               command = "set mymidi time format ms"
               mciSendStringA(command,NULL,0,0)
               flag=1
               'Strip the filename from the path
               for i=1 to len(filename)
                  if mid$(filename,i,1)="\\" then flag=i
               next i
               move w1,10,10
               print w1,right$(filename,len(filename)-flag)
               command = "info mymidi product"
               mciSendStringA(command,status,254,0)
               move w1,10,30
               print w1,status + " - " + right$(filename,3)+" file"
               command = "status mymidi length"
               mciSendStringA(command,status,254,0)
               status = left$(status,8)
               conSliderSetRange(w1,10,0,int(val(status)/1000))
               status=MStoTime(status)
               move w1,10,50
               print w1,"Length: ",status
               starttimer w1,200
               SETCURSOR w1,@CSARROW
            endif
         CASE 3
            command = "stop mymidi"
            mciSendStringA(command,NULL,0,0)
         CASE 4
            command = "play mymidi"
            mciSendStringA(command,NULL,0,0)
         CASE 2
            run = 0
      ENDSELECT
   CASE @IDTIMER
      command = "status mymidi position"
      mciSendStringA(command,status,254,0)
      status = left$(status,8)
      conSliderSetPos(w1,10,int(val(status)/1000))
      status=MStoTime(status)
      MOVE w1,10,70
      PRINT w1,"  Time: ",status
   CASE @IDCONTROL
      SELECT @CONTROLID
         CASE 11: 'Play
            command = "play mymidi"
            mciSendStringA(command,NULL,0,0)
         CASE 12: 'Pause
            command = "stop mymidi"
            mciSendStringA(command,NULL,0,0)
         CASE 13: 'Stop
            command = "stop mymidi"
            mciSendStringA(command,NULL,0,0)
            command = "seek mymidi to start"
            mciSendStringA(command,NULL,0,0)
            conSliderSetPos(w1,10,0)
      ENDSELECT
   CASE @IDHSCROLL
      'Seek
      min=conSliderGetPos(w1,10)
      command= "seek mymidi to "+str$(min*1000)
      mciSendStringA(command,NULL,0,0)
      command="play mymidi"
      mciSendStringA(command,NULL,0,0)
   CASE @IDCREATE
      CENTERWINDOW w1
ENDSELECT
RETURN 0
ENDSUB

Sub MStoTime(ins as string),string
   'Converts milliseconds to readable time format mm:ss
   string retval,strSec
   fltTime=val(ins)
   fltTime/=1000
   fltTime/=60
   min=int(fltTime)
   sec=int((fltTime-min)*100)
   strSec=ltrim$(str$(sec))
   retval=ltrim$(str$(min))+":"
   if len(strSec)=1 then retval=retval+"0"
   retval=retval+strSec
   return retval
EndSub

Support Amateur Radio  -  Have a ham  for dinner!

Andy

I have a copy of the control pack and it should include the files you need.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

arono

Hey Larry,

Thanks for your reply.  I wasn't sure you'd get my request since I don't see how to create a new post.  I've been away from this forum since April.  Is there something I'm missing on how to do this?

Anyway, your question to me was,"What kind of file do I want to play".  I listed a variety of formats:  AVI or MP4 or MOV or WMV, whichever would be best.


arono

Hi EGIL,

Thanks for the info.  I haven't studied the code yet but hopefully I can convert it to be used in an IWBASIC3 source code file.  But first I'll try Fletchie's ctl.lib to see how it works.

--------------------------------------------
ANDY,

I'd appreciate a copy of ctl.lib

Thanks to you all.