Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Embedding BSPlayer

  1. #1
    Constant Bitrate Needstorage's Avatar
    Join Date
    May 2004
    Location
    Belgium
    Posts
    176

    Cool 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. #2
    Raw Wave Confused's Avatar
    Join Date
    Aug 2003
    Location
    Essex, England
    Posts
    2,224
    Thanks for that information, Needstorage, I will definately have a look


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

  3. #3
    Maximum Bitrate mobileh1's Avatar
    Join Date
    Apr 2004
    Location
    San Francisco
    Posts
    454
    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

  4. #4
    I'm sorry, and you are....? frodobaggins's Avatar
    Join Date
    Jan 2003
    Location
    Ruston, LA
    Posts
    8,846
    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!

  5. #5
    Constant Bitrate Needstorage's Avatar
    Join Date
    May 2004
    Location
    Belgium
    Posts
    176
    Quote 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:\?

  6. #6
    Constant Bitrate Needstorage's Avatar
    Join Date
    May 2004
    Location
    Belgium
    Posts
    176
    Quote 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:\?

  7. #7
    I'm sorry, and you are....? frodobaggins's Avatar
    Join Date
    Jan 2003
    Location
    Ruston, LA
    Posts
    8,846
    Quote 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!

  8. #8
    Variable Bitrate NoPistonPC's Avatar
    Join Date
    Apr 2004
    Location
    Boston
    Posts
    360
    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:

    what video backend to use?

    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)

  9. #9
    I'm sorry, and you are....? frodobaggins's Avatar
    Join Date
    Jan 2003
    Location
    Ruston, LA
    Posts
    8,846
    Quote 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:

    what video backend to use?

    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!

  10. #10
    Variable Bitrate NoPistonPC's Avatar
    Join Date
    Apr 2004
    Location
    Boston
    Posts
    360
    Quote 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)

Page 1 of 2 12 LastLast

Similar Threads

  1. embedding copilot in mediacar
    By kuo in forum MediaCar
    Replies: 50
    Last Post: 10-04-2004, 05:05 AM
  2. Embedding a window in VB6 - Help
    By pioneer in forum Software & Software Development
    Replies: 9
    Last Post: 06-22-2004, 05:25 PM
  3. Embedding apps in vb6
    By Laidback in forum Software & Software Development
    Replies: 9
    Last Post: 05-09-2004, 08:44 PM
  4. WMP_EXE.exe
    By Fireball in forum ME Archive
    Replies: 9
    Last Post: 11-04-2003, 10:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •