Announcement

Collapse
No announcement yet.

Embedding BSPlayer

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Embedding BSPlayer

    Small tutorial on how to embed BSPlayer into your VB6 application.

    Starting up BSPlayer:
    - Just use Shell to start up the main BSPlayer exe and get the window handle to start:


    Code:
            Shell "c:\Program Files\BSPlayer\bsplayer.exe"
            Do
                DoEvents
                TheHandle = FindWindow("BSPlayer", "BSPlayer")
            Loop While TheHandle = 0
    Now we have the handle, put BSPlayer in our container. That's just a fancy word for a simple picturebox. (picContainer in my example)
    Now if you switch to full screen when playing a movie, it fills your container. So actually you can control its dimensions. (When I go to my main menu while playing a movie, the movie plays on in a small tumbnail-view)

    Code:
            SetParent TheHandle, Me.picContainer.hwnd
    Now you can start manipulating the thing.

    - request the status of the player:
    Code:
        Status = SendMessage(TheHandle, WM_BSP_CMD, BSP_GetStatus, 0
    // 0 - STOP
    // 1 - PAUSE
    // 2 - PLAY
    // 4 - No movie open
    - open a media file:
    Code:
        Dim cds As COPYDATASTRUCT
        Dim buf(1 To 255) As Byte
        Dim sFileName as string
        sFileName = "c:\media\media file.something"
    
        Call CopyMemory(buf(1), ByVal sFileName, Len(sFileName))
        With cds
            .dwData = BSP_OpenFile
            .cbData = Len(sFileName) + 1
            .lpData = VarPtr(buf(1))
        End With
        Call SendMessage(TheHandle, WM_COPYDATA, 0, cds)
    - pause, play, stop, fwd, back
    Code:
        SendMessage TheHandle, WM_BSP_CMD, BSP_Pause, 0
        SendMessage TheHandle, WM_BSP_CMD, BSP_Play, 0
        SendMessage TheHandle, WM_BSP_CMD, BSP_Stop, 0
        SendMessage TheHandle, WM_BSP_CMD, BSP_Forw, 0
        SendMessage TheHandle, WM_BSP_CMD, BSP_Rew, 0

    You will also need the next declares and types and all sort of API stuff:

    Code:
    Public Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Public Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function GetParent Lib "user32.dll" (ByVal hwnd As Long) As Long
    Public Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Public Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Public Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, lpRect As RECT) As Long
    Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
    Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    Public Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
    
    Public Type POINTAPI
            X As Long
            Y As Long
    End Type
    
    Public Const GWL_STYLE = (-16)
    Public Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
    Public Const WS_MAXIMIZEBOX = &H10000
    Public Const WS_MINIMIZEBOX = &H20000
    Public Const WS_SYSMENU = &H80000
    
    Public Const WM_KEYDOWN = &H100
    
    Public Const WM_CLOSE = &H10
    Public Const WM_USER = &H400
    Public Const WM_COPYDATA = &H4A
    Public Const WM_BSP_CMD = WM_USER + 2
    
    
    Public Type COPYDATASTRUCT
        dwData As Long   ' Use this to identify your message
        cbData As Long   ' Number of bytes to be transferred
        lpData As Long   ' Address of data
    End Type
    
    Public Const BSP_OpenFile = &H10108
    Public Const BSP_FS_SWITCH = 10
    Public Const BSP_Play = 20
    Public Const BSP_Rew = 14
    Public Const BSP_Forw = 15
    Public Const BSP_Pause = 21
    Public Const BSP_Stop = 22
    Public Const BSP_Exit = 77
    Public Const BSP_Mute = 35
    Public Const BSP_GetStatus = &H10102
    Public Const BSP_GetFileName = &H1010B
    
    Private Enum ESetWindowPosStyles
        SWP_SHOWWINDOW = &H40
        SWP_HIDEWINDOW = &H80
        SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
        SWP_NOACTIVATE = &H10
        SWP_NOCOPYBITS = &H100
        SWP_NOMOVE = &H2
        SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering
        SWP_NOREDRAW = &H8
        SWP_NOREPOSITION = SWP_NOOWNERZORDER
        SWP_NOSIZE = &H1
        SWP_NOZORDER = &H4
        SWP_DRAWFRAME = SWP_FRAMECHANGED
        HWND_NOTOPMOST = -2
    End Enum
    
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Now this was just an intro on embedding BSPlayer into a VB6 project. If you guys have any questions 'bout this, shoot.

    I'm using this stuff in conjunction with a lot of other API-calls to give it a true embedded look & feel. (manipulation of the positions and dimensions of the BSplayer windows, mouse cursor hiding in BSPlayer windows, catching clicks in BSPlayer windows...) So it is possible that the declares-section described has some extra API calls I forgot to clean out for this tutorial.
    Needstorage
    --------------------------

    Who the hell is general failure?!?
    And what the f@#k is he doing reading my drive C:\?

  • #2
    Thanks for that information, Needstorage, I will definately have a look


    Garry
    Co-Developer of A.I.M.E.E
    www.aimee.cc

    Comment


    • #3
      What does bsplayer have that either winamp or WMP lacks?
      .//Daren
      (Epia M10000/C134) (C137/MII 10000) Liliput /Opus 150W/DVD/512MB/80GB/Hummer H1
      MediaCar/CoPilot7/Routis

      Comment


      • #4
        Wrong thread. Oops.
        [H]4 Life
        My next generation Front End is right on schedule.
        It will be done sometime in the next generation.
        I'm a lesbian too.
        I am for hire!

        Comment


        • #5
          Originally posted by mobileh1
          What does bsplayer have that either winamp or WMP lacks?
          WMP?! Are you kidding me?
          Way too much overkill! (I'd probably need to implement swapfile-technology into my Embedded XP distro in order for WMP to play an mp3 )

          Winamp... well, besides winamp as audio player, i don't know why I should choose for it. (Does winamp play mpg/avi/... DivX, XVid, ... ?)

          BSPlayer is pretty small and does not require a lot of resources and it starts fast. It has built in subtitle support. (Subs, srt, ...) and it has:
          - custom AR (aspect ratios)
          - Fully Skinnable (if you are not "stealth"-embedding it)
          - Remote control support (WinLIRC)
          - Multiple Audio Streams in AVI's supported
          - ...

          just look at this page for more detailed info on BSPlayer.
          Needstorage
          --------------------------

          Who the hell is general failure?!?
          And what the f@#k is he doing reading my drive C:\?

          Comment


          • #6
            Originally posted by frodobaggins
            Wrong thread. Oops.
            Frodo, can you explain this? Or have you been drinking too much again?
            Needstorage
            --------------------------

            Who the hell is general failure?!?
            And what the f@#k is he doing reading my drive C:\?

            Comment


            • #7
              Originally posted by Needstorage
              Frodo, can you explain this? Or have you been drinking too much again?
              I had two windows open.
              Pasted into wrong quick reply.
              [H]4 Life
              My next generation Front End is right on schedule.
              It will be done sometime in the next generation.
              I'm a lesbian too.
              I am for hire!

              Comment


              • #8
                I hate to preach, but I still don't understand why no one has bothered to use DirectShow to play music and videos (without needing to run winamp, WMP, BSPlayer, or any other external app) with just a few lines of code:

                http://www.mp3car.com/vbulletin/show...1&postcount=13

                Maybe I'm missing something obvious... if so, please enlighten me.
                1994 RX-7, EPIA P4-ITX w/ Celeron 2.4 Ghz, Arise PSU, Xenarc 700TSV (new model)

                Comment


                • #9
                  Originally posted by NoPistonPC
                  I hate to preach, but I still don't understand why no one has bothered to use DirectShow to play music and videos (without needing to run winamp, WMP, BSPlayer, or any other external app) with just a few lines of code:

                  http://www.mp3car.com/vbulletin/show...1&postcount=13

                  Maybe I'm missing something obvious... if so, please enlighten me.
                  because the problem of handling visualizations yourself. As well as a lot of othe nice things the other objects offer.

                  Frodo
                  [H]4 Life
                  My next generation Front End is right on schedule.
                  It will be done sometime in the next generation.
                  I'm a lesbian too.
                  I am for hire!

                  Comment


                  • #10
                    Originally posted by frodobaggins
                    because the problem of handling visualizations yourself. As well as a lot of othe nice things the other objects offer.
                    While there isn't visualization support out-of-the-box, you can use 3rd party, open-source DirectShow filters, such as DC-DSP which will let you do cool things like use WinAmp visualization plugins and provides a parametric equalizer and other sounds filters.
                    1994 RX-7, EPIA P4-ITX w/ Celeron 2.4 Ghz, Arise PSU, Xenarc 700TSV (new model)

                    Comment


                    • #11
                      Originally posted by NoPistonPC
                      While there isn't visualization support out-of-the-box, you can use 3rd party, open-source DirectShow filters, such as DC-DSP which will let you do cool things like use WinAmp visualization plugins and provides a parametric equalizer and other sounds filters.
                      Using DirectSound and a combination of FFT forumlas/aglorithms you can make your own Visualization system. That is what I had to do with MMC. We are supporting third part as well as our own system. You then just export that FFT data to the developers of the Visuals. I agree with Frodo though, that there is a lot of nice objects that support this already. I just did it so I could learn about DirectSound and sound programming related stuff like FFT (Fast Fourier Transform)

                      http://mathworld.wolfram.com/FastFourierTransform.html
                      http://ourworld.compuserve.com/homep...ifowit/fft.htm
                      http://en.wikipedia.org/wiki/Fast_Fourier_transform

                      Take care
                      Ben S. Stahlhood II
                      Hybrid Mobile
                      MMC/Transcend Developer
                      --------------------------------------
                      http://www.hybrid-mobile.com/
                      http://www.cocoamachine.com/
                      http://weblogs.asp.net/bstahlhood/

                      Comment


                      • #12
                        Originally posted by frodobaggins
                        because the problem of handling visualizations yourself. As well as a lot of othe nice things the other objects offer.

                        Frodo
                        lazy programmers.... you want everything done for you
                        '98 Explorer Sport
                        http://mp3car.zcentric.com (down atm)
                        AMD 800mhz 192megs RAM 60gig hard drive 9 inch widescreen VGA
                        80% done

                        Comment


                        • #13
                          Originally posted by NoPistonPC
                          I hate to preach, but I still don't understand why no one has bothered to use DirectShow to play music and videos (without needing to run winamp, WMP, BSPlayer, or any other external app) with just a few lines of code:

                          http://www.mp3car.com/vbulletin/show...1&postcount=13

                          Maybe I'm missing something obvious... if so, please enlighten me.
                          I use DirectSound/DirectShow for everything in Mobile Media Center. That is why it is so fast. I even wrote some portions in pure ILASM code so that I could make sure of the best tweaks. You do not need any other programs to piggy back of off. So I know what you mean. This is a very huge pain in the arse though, since you have to do a lot of things yourself, where other SDK's and software like Winamp already have it done and tested for many years.
                          Ben S. Stahlhood II
                          Hybrid Mobile
                          MMC/Transcend Developer
                          --------------------------------------
                          http://www.hybrid-mobile.com/
                          http://www.cocoamachine.com/
                          http://weblogs.asp.net/bstahlhood/

                          Comment


                          • #14
                            Originally posted by hijinks21
                            lazy programmers.... you want everything done for you
                            Or they just want to save some of the time they volunteer, so they have a life...
                            Ben S. Stahlhood II
                            Hybrid Mobile
                            MMC/Transcend Developer
                            --------------------------------------
                            http://www.hybrid-mobile.com/
                            http://www.cocoamachine.com/
                            http://weblogs.asp.net/bstahlhood/

                            Comment


                            • #15
                              Originally posted by HybridEngineer
                              Or they just want to save some of the time they volunteer, so they have a life...
                              didn't see the sarcaism there did ya??
                              '98 Explorer Sport
                              http://mp3car.zcentric.com (down atm)
                              AMD 800mhz 192megs RAM 60gig hard drive 9 inch widescreen VGA
                              80% done

                              Comment

                              Working...
                              X