|
Post by davemartin on Nov 1, 2018 18:18:01 GMT -5
If I remember correctly from years ago, Liberty Basic has no command to run any type of video file (Like it's counter part - 'Playwav'. Has anything changed? Is there a way to run any type of video file within Liberty Basic Code? Just curious as I haven't heard much from LB lately. Thanks in advance. Dave
|
|
|
Post by Brandon Parker on Nov 1, 2018 21:10:59 GMT -5
There's no built in command, but you can use many different outside facilities to achieve this including mciSendString. Check it out; there are also quite a few examples out there in the wild as well. I'm sure someone will post one prior to me finding an example I have stored somewhere. In the Music and Sound thread you can see where Rod has been enjoying the use of mciSendString, but it is capabable of so -- so many more things than just sound. {:0) Brandon R. Parker
|
|
|
Post by atomose on Nov 2, 2018 20:09:16 GMT -5
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Jun 8, 2020 8:42:31 GMT -5
Are there examples with "mciSendString" to play a video in a graphicbox. (avi, mp4,..)
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Jun 9, 2020 9:44:21 GMT -5
I found something to play a .avi (Gordon Brown, UK)
nomainwin
path$ = "C:\DOS"
open "winmm.dll" for dll as #mm
[pick]
WindowWidth=196:WindowHeight=200
UpperLeftX=DisplayWidth-200
UpperLeftY=DisplayHeight-200
button #1, "Tiny Scrn",[Tiny],UL,100,10,80,26
button #1, "Small Scr",[Small],UL,10,10,80,26
button #1, "Full Scrn",[Full],UL,100,40,80,26
button #1, "Half Scrn",[Half],UL,10,40,80,26
button #1, "Pause",[pause],UL,10,70,80,26
button #1, "Resume",[resume],UL,100,70,80,26
button #1, " Stop ",[stop],UL,10,100,80,26
button #1, " Next ",[sel],UL,100,100,80,26
button #1, "Select",[new],UL,10,130,80,26
button #1, " QUIT ",[quit],UL,100,130,80,26
open "Video Player" for window_nf as #1
print #1, "trapclose [quit]"
mainH=hWnd(#1) : gosub [boxhold]
DefaultDir$ = path$
filedialog "Pick any Video File", "*.avi;*.mpeg;*.wmv;*.mp4;*.flv",m$
if m$="" then [quit]
sFile$ = noPath$(m$)
plen = len(m$)-len(sFile$)
path$ = left$(m$,plen)
DefaultDir$ = path$
[loop]
ex$ = Upper$(right$(m$,3))
if ex$ = "FLV" or ex$ = "MP4" then [flv]
Title$="Pause Me!"
wait
[Tiny]
scrw = 0 : scrh = 0
goto [open]
[Small]
scrw = int(DisplayWidth/4) : scrh = int(DisplayHeight/4)
goto [open]
[Half]
scrw = int(DisplayWidth/1.5) : scrh = int(DisplayHeight/1.5)
goto [open]
[Full]
Title$="Full Screen - No Pause or Resume"
scrw = DisplayWidth : scrh = DisplayHeight
xpos = 1 : ypos= 1 : goto [max]
[open]
xpos = 160+ux : ypos = 20+uy
[max]
sFile$ = noPath$(m$)
plen = len(m$)-len(sFile$)
path$ = left$(m$,plen)
DefaultDir$ = path$
m$=GetShortPathName$(m$)
r$=mciSendString$("open "+m$+" type MpegVideo alias movie")
r$=mciSendString$("window movie text " + chr$(34) + Title$ + chr$(34))
r$=mciSendString$("put movie window at ";xpos;" ";ypos;" ";scrw;" ";scrh)
r$=mciSendString$("status movie length")
mlength=val(r$) 'length of mpg
timer 100, [closemovie]
movieOpen=1
r$=mciSendString$("play movie")
goto [loop]
[closemovie] 'See which part is currently
'playing and if it is the last,
'then close movie.
r$=mciSendString$("status movie position")
if val(r$)<mlength then [loop]
r$=mciSendString$("close movie")
timer 0
movieOpen=0
goto [loop]
[stop]
r$=mciSendString$("close movie")
goto [loop]
[pause]
r$=mciSendString$("pause movie")
goto [loop]
[resume]
r$=mciSendString$("resume movie")
goto [loop]
[new]
r$=mciSendString$("close movie")
close #1
goto [pick]
[sel]
r$=mciSendString$("close movie")
close #1 : win3 = 0 : goto [pick]
[flv]
CALL ShellExecute hWnd, m$
[quit]
if movieOpen then r$=mciSendString$("close movie")
close #1
confirm "OK to Quit?"; quit$
if quit$ = "no" then [pick]
close #mm : end
Function noPath$(t$)
while instr(t$, "\")
t$ = mid$(t$, 2)
wend
noPath$ = t$
end function
Function GetShortPathName$(lPath$)
lPath$=lPath$+chr$(0)
sPath$=space$(256)
lenPath=len(sPath$)
open "kernel32" for dll as #k
calldll #k, "GetShortPathNameA",lPath$ as ptr,_ sPath$ as ptr,lenPath as long,r as long
close #k
GetShortPathName$=left$(sPath$,r)
end function
Function mciSendString$(s$)
'Buffer will contain a return string from
'the function, if there is one.
buffer$=space$(1024)+chr$(0)
calldll #mm,"mciSendStringA",s$ as ptr,buffer$ as ptr,_ 1028 as long, 0 as long, r as long
'truncate returned string at null character
buffer$=left$(buffer$, instr(buffer$, chr$(0)) - 1)
if r>0 then
mciSendString$="error"
else
mciSendString$=buffer$
end if
End Function
[boxhold]
open "user32" for dll as #user ' prevents losing box
toTop=(-1 or 0)
flags=_SWP_NOMOVE or _SWP_NOSIZE
calldll #user,"SetWindowPos",mainH as ushort,toTop as short,_ 0 as short,0 as short,0 as short,0 as short,flags as ushort,_ result as void
close #user : return
Sub ShellExecute hWnd, cf$
parameter = _SW_SHOWNORMAL ' set up for viewing
lpszOp$ = "open" + Chr$(0) ' "open" or "play" or "print"
lpszFile$ = cf$ + Chr$(0)
lpszDir$ = DefaultDir$ + Chr$(0)
lpszParams$="" + Chr$(0)
CallDLL #shell32, "ShellExecuteA", hWnd As long,lpszOp$ As ptr,lpszFile$ As ptr,_ lpszParams$ As ptr,lpszDir$ As ptr,parameter As long, result As long
End Sub
|
|