Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Libraries (Windows)
#29
@Pete

First question. Does the video that doesn't play play in VLC, or WMP, or a media player? What operating system are you using for that?

Attached is an MJPG video with ADPCM sound (output of a program written in QB64PE without C language) - the quality is terrible but it's for the purpose of testing the function for you. This video plays in this player for me. How does it work for you? Do you have the necessary codecs on your computer? There were 2 small bugs in that program that test the error return code, but that doesn't affect the playback itself. Try it and let me know.

Code: (Select All)


Option _Explicit

Declare Dynamic Library "winmm"
    Function mciSendStringA& (lpstrCommand As String, lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As _Offset)
    Function mciGetErrorStringA& (ByVal dwerrsor As Long, lpstrBuffer As String, ByVal uLength As Long)
End Declare

Dim handle&: handle& = _NewImage(800, 600, 32)
Screen handle&
_Title "QB64 Video"

Dim hwnd As _Offset: hwnd = _WindowHandle

Dim filename As String, aliasName As String
filename = "aaa_dop.avi"
aliasName = "vid"

Dim cm As String, e As Long
Dim dummy As String: dummy = Space$(1)

' 1) Open
cm = "open " + Chr$(34) + filename + Chr$(34) + " type mpegvideo alias " + aliasName
e = mciSendStringA&(cm, dummy, 0, 0): MCI_Check e, cm

' 2) Attach to QB64 window handle (more stable than parent/style child)
cm = "window " + aliasName + " handle " + LTrim$(Str$(hwnd))
e = mciSendStringA&(cm, dummy, 0, 0): MCI_Check e, cm

' 3) Set destination rect (not "put window at")
cm = "put " + aliasName + " destination at 0 0 800 600"
e = mciSendStringA&(cm, dummy, 0, 0): MCI_Check e, cm

' 4) Play
cm = "play " + aliasName
e = mciSendStringA&(cm, dummy, 0, 0): MCI_Check e, cm

Do
    _Limit 60
    _Display ' let s messages going and window as active (QB64 help)
Loop Until InKey$ <> ""
Dim N As Long
N = mciSendStringA&("stop " + aliasName, dummy, 0, 0)
N = mciSendStringA&("close " + aliasName, dummy, 0, 0)
End

Sub MCI_Check (errsCode As Long, where As String)
    Dim n As Long
    If errsCode <> 0 Then
        Dim msg As String
        msg = Space$(256)
        n = mciGetErrorStringA&(errsCode, msg, Len(msg))
        Print "MCI error ("; errsCode; "): "; where
        Print RTrim$(msg)
        Sleep
        End
    End If
End Sub

ZIP file contains 20 seconds AVI (MJPG/ADPCM)


Attached Files
.zip   aaa_dop.zip (Size: 1.1 MB / Downloads: 12)


Reply


Messages In This Thread
Dynamic Libraries (Windows) - by Petr - 12-08-2025, 06:48 PM
RE: Dynamic Libraries - by Petr - 12-08-2025, 07:12 PM
RE: Dynamic Libraries - by Petr - 12-08-2025, 07:52 PM
RE: Dynamic Libraries - by Jack - 12-08-2025, 08:41 PM
RE: Dynamic Libraries - by Petr - 12-09-2025, 07:21 PM
RE: Dynamic Libraries - by Petr - 12-11-2025, 04:19 PM
RE: Dynamic Libraries - by Petr - 12-12-2025, 10:00 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 05:56 PM
RE: Dynamic Libraries - by 2112 - 12-13-2025, 07:06 PM
RE: Dynamic Libraries - by ahenry3068 - 12-13-2025, 07:47 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 07:41 PM
RE: Dynamic Libraries - by 2112 - 12-13-2025, 08:23 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 08:36 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 09:03 PM
RE: Dynamic Libraries - by ahenry3068 - 12-13-2025, 11:16 PM
RE: Dynamic Libraries - by Petr - 12-14-2025, 12:15 AM
RE: Dynamic Libraries - by Petr - 12-15-2025, 08:22 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-15-2025, 06:30 PM
RE: Dynamic Libraries (Windows) - by Mad Axeman - 12-19-2025, 02:37 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 07:45 PM
RE: Dynamic Libraries (Windows) - by Steffan-68 - 12-18-2025, 08:31 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 08:55 PM
RE: Dynamic Libraries (Windows) - by Steffan-68 - 12-18-2025, 09:48 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-18-2025, 09:32 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 11:53 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-19-2025, 06:40 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 03:08 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 10:35 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 10:54 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 11:20 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-19-2025, 11:37 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-20-2025, 10:22 PM
RE: Dynamic Libraries (Windows) - by SMcNeill - 12-20-2025, 11:03 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-21-2025, 05:40 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-22-2025, 08:23 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-23-2025, 09:06 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-24-2025, 09:54 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-25-2025, 10:02 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-26-2025, 11:14 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-27-2025, 01:35 PM
RE: Dynamic Libraries (Windows) - by MasterGy - 12-27-2025, 07:23 PM
RE: Dynamic Libraries (Windows) - by Petr - 01-07-2026, 06:31 PM
RE: Dynamic Libraries (Windows) - by Petr - 01-07-2026, 09:13 PM
RE: Dynamic Libraries (Windows) - by Petr - 02-24-2026, 06:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamic Libraries (Linux) Petr 19 1,156 12-29-2025, 09:52 PM
Last Post: Petr

Forum Jump:


Users browsing this thread: 1 Guest(s)