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

Winmm.dll (2 years old) and Winmmbase.dll (6 years old) are in my system32 windows folder. No other similar files or version available. Placing these two files in the QB64PE folder made no difference in this case.

My system is 9 years old, and maybe these drivers are not up to date enough. Thanks for letting me know you had a similar situation. I thought I had missed some posted forum attachment.

Pete Smile
Reply
#22
Problem, you talk about create program from reply #10. Use program from reply #14, this run correctly here (MJPG + ADPCM, or MJPG + PCM). Windows 10 64bit, all updates.


Reply
#23
(12-18-2025, 08:55 PM)Pete Wrote: @Steffan-68

Winmm.dll (2 years old) and Winmmbase.dll (6 years old) are in my system32 windows folder. No other similar files or version available. Placing these two files in the QB64PE folder made no difference in this case.

My system is 9 years old, and maybe these drivers are not up to date enough. Thanks for letting me know you had a similar situation. I thought I had missed some posted forum attachment.

Pete Smile

For me it's 35



.bmp   screenshot(30).bmp (Size: 1.34 MB / Downloads: 120)
Reply
#24
I guess that's why they named it: WOW

I found 3, but none work when copied to the QB folder.

Pete Big Grin
Shoot first and shoot people who ask questions, later.
Reply
#25
WinMM is like nearly as old as PETE! 

What is it you guys are trying to do? Can i help please as right now the Win API is my bi^ch!

John
Reply
#26
I wish I was only that old. I suggest you invest in wax. My next birthday is coming soon!

Hey John,

Trying to get an AVI file to play on Petr's QB64 vid player: https://qb64phoenix.com/forum/showthread...9#pid37859

I get short sound loop only, and an error message that the app can't find the decompressor. So Petr wrote back to use post #14. I just tried it, but it causes the app to crash after about 10 seconds of that spinning windows progress circle.

Oh well, maybe another day.

Pete
Reply
#27
(12-15-2025, 06:30 PM)Petr Wrote: @Mad Axeman, I didn't forget. Here's a version of ListMenu for Windows without the top search bar. This time it's in the form of a .h file. This eliminates the need to create 32-bit and 64-bit DLLs. 
Thanks. At the moment work is getting in the way of things but that should stop next week. I'll take a look at it then.
Oh look. A sig line :-)
Reply
#28
Pete,  YOURE OLD MAN! Accept it! (Also if you talk to Ted, say hi from me!)

Now, i can do it one of two ways but MY way is the best and easiest....so the first way (QB64 only code) aint gonna happen!

From me telling Googles Ai the premise and then ages making tweaks and telling it to not be so smart as Im dumb here's and idea...

FOR YOU ill make anything if i can or go for Aspirins after 2 days of failiure! 

TELL ME how youd want it, the requirements, what does QB64 need to see? (load, play, pause, volume etc...) and then bish bash bosh and you'll owe me a +1

Me, my idea is to allow for any number of AVIs to be loaded, each ones state stored internally and then each AVI referenced via index. QB64 will only ever need the index, when loading a new avi the index returned is that file and then all concurrent commands take said index and do their thing!

John

*NOTE the below is me chatting with google

To implement the QB_AVI system, we will use a C++ structure (UDT) to track each video’s state and store them in a std::vector. The C++ layer will return a simple index to QB64.
1. The C++ Core (QB_AVI.cpp)
This code manages the video metadata. We use mciSendCommand for speed and efficiency.
cpp
#include <windows.h>
#include <mmsystem.h>
#include <vector>
#include <string>

#define QB_EXPORT extern "C" __declspec(dllexport)

struct QB_AVI_STATE {
    UINT deviceID;
    long start;
    long current;
    long end;
    int vol; // 0-1000
};

std::vector<QB_AVI_STATE> AVIs;

QB_EXPORT int QB_AVI_Load(const char* filename) {
    MCI_OPEN_PARMS openParms = {0};
    openParms.lpstrDeviceType = "avivideo";
    openParms.lpstrElementName = filename;

    if (mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD_PTR)&openParms) == 0) {
        QB_AVI_STATE vid;
        vid.deviceID = openParms.wDeviceID;
       
        // Get length in frames
        MCI_STATUS_PARMS status = {0};
        status.dwItem = MCI_STATUS_LENGTH;
        mciSendCommand(vid.deviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&status);
       
        vid.start = 0;
        vid.end = status.dwReturn;
        vid.current = 0;
        vid.vol = 500;
       
        AVIs.push_back(vid);
        return (int)AVIs.size() - 1;
    }
    return -1;
}

QB_EXPORT void QB_AVI_Render(int index, HWND hwnd, int x, int y, int w, int h) {
    if (index < 0 || index >= AVIs.size()) return;
    QB_AVI_STATE &v = AVIs[index];

    // Bind to window
    MCI_DGV_WINDOW_PARMS win = {0};
    win.hWnd = hwnd;
    mciSendCommand(v.deviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&win);

    // Set destination rectangle
    MCI_DGV_PUT_PARMS put = {0};
    put.rc = { (LONG)x, (LONG)y, (LONG)(x + w), (LONG)(y + h) };
    mciSendCommand(v.deviceID, MCI_PUT, MCI_DGV_PUT_DESTINATION | MCI_DGV_RECT, (DWORD_PTR)&put);

    // Play from current
    MCI_PLAY_PARMS play = {0};
    mciSendCommand(v.deviceID, MCI_PLAY, 0, (DWORD_PTR)&play);
}

QB_EXPORT long QB_AVI_GetPos(int index) {
    if (index < 0 || index >= AVIs.size()) return 0;
    MCI_STATUS_PARMS status = {0};
    status.dwItem = MCI_STATUS_POSITION;
    mciSendCommand(AVIs[index].deviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&status);
    return status.dwReturn;
}
Use code with caution.

2. QB64 Library Declaration
In QB64, you link the compiled DLL. Note the use of _OFFSET for the window handle (essential for 64-bit compatibility in 2025).
vb
DECLARE DYNAMIC LIBRARY "QB_AVI"
    FUNCTION QB_AVI_Load% (filename AS STRING)
    SUB QB_AVI_Render (BYVAL index AS LONG, BYVAL hwnd AS _OFFSET, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL w AS LONG, BYVAL h AS LONG)
    FUNCTION QB_AVI_GetPos& (BYVAL index AS LONG)
END DECLARE

' Usage
SCREEN _NEWIMAGE(1280, 720, 32)
vIndex% = QB_AVI_Load("test.avi" + CHR$(0))

IF vIndex% >= 0 THEN
    QB_AVI_Render vIndex%, _WINDOWHANDLE, 0, 0, 1280, 720
    DO
        LOCATE 1, 1: PRINT "Current Frame:"; QB_AVI_GetPos(vIndex%)
        _LIMIT 60
    LOOP UNTIL _KEYHIT = 27
END IF
Use code with caution.

Why this is a "Cake Walk"
Vector Management: QB64 only passes a LONG index. You can load 100 AVIs and the C++ side manages the memory via the vector.
UDT Logic: Properties like start, end, and vol are stored in the C++ struct. You can add getters/setters easily (e.g., QB_AVI_SetVol).
Handle Safety: By using _WINDOWHANDLE, the video is clipped and rendered directly by the Windows display driver into your QB64 workspace.


SIDE NOTE : From my current DEV ive learned that there is NEXT TO NOTHING we cant add to QB64 using C/C++ wrappers and declare lib...SO IF ANYONE WANTS ANYTHING else like this...ask and i will deliver or tell you im too dumb to do it!

Second note @ DEVS : ADD A _Screen function...I KNOW that GL 4.6, DX 9-11/12 and VULKAN are not HARD to implement. In fact id wager that at least for Gl no more than 5 or 6 lines of code need to be added to allow Qb64 to use all GL functionality! (Not bragging here but Galleon used SFML to demo Declare library and GL. He was VERY against adding GL to QB64 until i showed my work, begged and pleaded and eventually he made the work around we have today) That was 2011 and even then it was OLD! My new GDK allows for any number of screens in any render mode, GL DX etc...so if you dont add it I will!

John
Reply
#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
#30
This is a video player written in C++. Attached are the 32-bit and 64-bit DLLs, the source code,  BAS program and all the files needed for compilation. The only bug in the program is that it cannot be run in fullscreen mode, because the video window then hides behind the QB64PE screen. I will be porting this program to Linux in the near future as well - I finally finished installing Linux yesterday to laptop with everything that’s needed.

The program includes options to fast-forward and rewind, play at reduced, normal, or increased speeds, control the volume, and pause/resume the video. Of course, you can position it anywhere on the screen (with adjustable width and height for the video playback). There is also an option to zoom the video in or out using the + and - buttons.


Attached Files
.zip   Pow2.zip (Size: 162.83 KB / Downloads: 14)


Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)