Best video file format?

Windows specific questions.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: How to load ATL in order to embed window movie player?

Postby datwill310 » Jul 29, 2015 18:18

Tourist Trap wrote:Go for windows SDK, bring back MSDN in the same time, assumed you've got very large hard disks. Then take also visual studio express edition, grab code block complete IDE. Those are a good basis for starting being at ease if you are to do some widerange programing. Visual studio would allow you to play easily some examples that are related to dot net, and Code Block would grant you access to C/C++ world in a friendly yet powerful fashion. By the way dot net frameworks are also huge downloads... You may need them from version 2 to 4 and further if you decide to use visual basic.

As a matter of fact I do have .NET framework - it took forever to download! I'll look up SDK.
After looking it up and viewing the download page: I think I do have this: I remember it from downloading .NET...
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: How to load ATL in order to embed window movie player?

Postby Tourist Trap » Jul 29, 2015 18:30

datwill310 wrote:As a matter of fact I do have .NET framework - it took forever to download! I'll look up SDK.
After looking it up and viewing the download page: I think I do have this: I remember it from downloading .NET...

Have you visual studio then? I ask because if you do, you can use windows media player as a graphical control that you just put as a textbox or anything inside your gui. Maybe then you could write your game mixing vb and freebasic via dll calls. At least you would have your player.
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

ATL / WindowsMediaPlayer

Postby Tourist Trap » Jul 30, 2015 11:44

Damn I've missed this at the very start but the forum had provided everything needed to embed wmp via ATL. That doesn't solve every question but this should be what you were asking for at first place.

Take a look at this nice code and at the topic which link appears on top to read the author's comment.

Code: Select all

'Usage of ATL lib for embedding WMPlayer.ocx object
'source by MichaelW
'http://www.freebasic.net/forum/viewtopic.php?f=6&t=15962&hilit=createwindow
'==============================================================================
#Include "windows.bi"
'==============================================================================

Function WindowProc( byval hWnd as HWND,_
                      byval uMsg as uint,_
                      byval wParam as WPARAM,_
                      byval lParam as LPARAM ) as LRESULT
     static as any ptr hLib
     static as HWND hwndCal
     dim as sub AtlAxWinInit
     select case uMsg
        case WM_CREATE
             hLib = DylibLoad( "atl.dll" )
             if hLib = 0 then
                 MessageBox( hWnd, "DylibLoad error", 0, 0 )
             end if
             AtlAxWinInit = DylibSymbol( hLib, "AtlAxWinInit" )
             if AtlAxWinInit = 0 then
                 MessageBox( hWnd, "DylibSymbol error", 0, 0 )
             end if
             AtlAxWinInit()
             hwndCal = CreateWindow( "AtlAxWin", "WMPlayer.ocx", _
                                     WS_CHILD or WS_VISIBLE, 0, 0, _
                                     390, 275, hWnd, NULL, _
                                     GetModuleHandle(NULL), NULL)
             if hwndCal = 0 then
                 MessageBox( hWnd, "CreateWindow error", 0, 0 )
             end if
            
         case WM_COMMAND
             select case wParam
                case IDCANCEL
                     DestroyWindow( hWnd )
             end select
        case WM_CLOSE
             DestroyWindow( hWnd )
        case WM_DESTROY
             PostQuitMessage( null )
        case else
             return DefWindowProc( hWnd, uMsg, wParam, lParam )
     end select
      
     return 0
End function
'==============================================================================
Dim as integer wx, wy, nWidth, nHeight
Dim as WNDCLASSEX wcx
Dim as HWND hWnd
Dim as MSG wMsg
Dim as string class_name = "class_name"

With wcx
     .cbSize = sizeof( WNDCLASSEX )
     .style = CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
     .lpfnWndProc = cast( WNDPROC, @WindowProc )
     .cbClsExtra = null
     .cbWndExtra = null
     .hInstance = GetModuleHandle( null )
     .hbrBackground = cast( HBRUSH,COLOR_WINDOW + 1 )
     .lpszMenuName = null
     .lpszClassName = strptr(class_name)
     .hIcon = LoadIcon( null, IDI_APPLICATION )
     .hCursor = LoadCursor ( null, IDC_ARROW )
     .hIconSm = 0
End with

RegisterClassEx( @wcx )

nWidth = 400
nHeight = 300
wx = (GetSystemMetrics( SM_CXSCREEN ) / 2) - nWidth / 2
wy = (GetSystemMetrics( SM_CYSCREEN ) / 2) - nHeight / 2

hWnd = CreateWindowEx( WS_EX_OVERLAPPEDWINDOW, _
                        strptr(class_name), _
                        "Test", _
                        WS_OVERLAPPED or WS_SYSMENU or WS_VISIBLE, _
                        wx, _
                        wy, _
                        nWidth, _
                        nHeight, _
                        null, _
                        null, _
                        GetModuleHandle( null ), _
                        null )

ShowWindow( hWnd, SW_SHOWNORMAL )

Do while GetMessage( @wMsg, null, 0, 0 ) <> 0
     if IsDialogMessage( hWnd, @wMsg ) = 0 then
         TranslateMessage( @wMsg )
         DispatchMessage( @wMsg )
     end if
Loop
'==============================================================================
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Best video file format?

Postby datwill310 » Jul 30, 2015 13:28

I'll try this code out right away!
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: ATL and WIdows Media Player

Postby datwill310 » Jul 30, 2015 13:31

This is perfect! Thank you: just what I needed! I will research further into the matter! If I could thank you twice, I would!
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: ATL and WIdows Media Player

Postby Tourist Trap » Jul 30, 2015 13:41

@datwill310, thanks shoud go to MickaelW who provided a code perfectly written. Let us know if you succeed to make the control work properly.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: ATL and WIdows Media Player

Postby datwill310 » Jul 30, 2015 15:05

Tourist Trap wrote:@datwill310, thanks shoud go to MickaelW who provided a code perfectly written. Let us know if you succeed to make the control work properly.

I will; and I will let you know.
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: Best video file format?

Postby grindstone » Jul 31, 2015 8:27

Nice window. And how can I make it play videos now? Am I too stupid, or isn't it implemented yet?
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: Best video file format?

Postby Tourist Trap » Jul 31, 2015 9:12

grindstone wrote:or isn't it implemented yet?

Seems something missing to have access to the player yes.
Maybe usage of an other function like AtlAxGetControl ?

AtlAxGetControl
https://msdn.microsoft.com/en-us/librar ... 10%29.aspx
Obtains a direct interface pointer to the control contained inside a specified window given its handle.

ATLAPI AtlAxGetControl( HWND h, IUnknown** pp );

Parameters
h : [in] A handle to the window that is hosting the control.
pp : [out] The IUnknown of the control being hosted.
Return : Value One of the standard HRESULT values.

Requirements
Header: atlhost.h
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: Best video file format?

Postby grindstone » Jul 31, 2015 9:20

This way you can embedd VLC-player to your programme:

Code: Select all

#Include "windows.bi"

Declare Sub play(vidFile As String)
Declare Sub rc(order As String)

Dim Shared As HWND hWndThisWindow, hWndRC, hWndVLC
Dim As String g, vidFile
Dim As ZString*100 text
Dim As STARTUPINFO siVLC
Dim As PROCESS_INFORMATION pi
Dim As WINDOWPLACEMENT wpDF, wpVLC

hWndThisWindow = GetForegroundWindow() 'get window handle

'move console window to the top left corner
GetWindowPlacement(hWndThisWindow,@wpDF)
With wpDF.rcNormalPosition
   .right = .right - .left + 1
   .left = 1
   .bottom = .bottom - .top + 1
   .top = 1
End With
SetWindowPlacement(hWndThisWindow,@wpDF)

GetStartupInfo(@siVLC) 'get default values
'set new values
text = "Window" 'new title of the rc-window (for certain finding)
siVLC.lpTitle = @text 'set new window title
siVLC.dwFlags = STARTF_USESHOWWINDOW 'unlock display options
siVLC.wShowWindow = SW_HIDE 'hide rc-window

'launch VLC-Player with remote control (align path if necessary)
CreateProcess(0,"C:\Programme\VideoVLC\vlc.exe --extraintf rc",0,0,0,0,0,0,@siVLC,@pi)

Do 'wait till rc-window is opened
   Sleep 1
Loop Until FindWindow(0,"Window")
hWndRC = FindWindow(0,"Window") 'memorize window handle

Do 'wait, till VLC-Player is running
   hWndVLC = FindWindow(0,"VLC media player")
   Sleep 1
Loop Until IsWindowVisible(hWndVLC)

'place VLC beneath console window
GetWindowPlacement(hWndVLC,@wpVLC)
With wpVLC.rcNormalPosition
   .right = .right - .left + 1
   .left = 1
   .bottom = .bottom - .top + 1 + wpDF.rcNormalPosition.bottom
   .top = 1 + wpDF.rcNormalPosition.bottom
End With
SetWindowPlacement(hWndVLC,@wpVLC)

SetForegroundWindow(hWndThisWindow)
Print "1 - Video 1"
Print "2 - Video 2"
Print "3 - Video 3"

Do
   g = InKey
   Select Case g
      Case "1"
         vidFile = "d:\videos\video1.avi" 'replace with path / name of existing video file
         Exit Do
      Case "2"
         vidFile = "d:\videos\video2.avi"
         Exit Do
      Case "3"
         vidFile = "d:\videos\video3.avi"
         Exit Do   
   End Select
Loop
play(vidFile)

Cls
Print "F1 = Toggle pause"
Print "F2 = Quit"

Do
   g = InKey
   Select Case g
      Case Chr(255,59) 'F1
         rc("pause") 'toggle pause
      Case Chr(255,60) 'F2
         rc("quit") 'quit VLC-Player
         Sleep 1000 'wait till VLC has closed
         SendMessage(hWndRC,WM_CLOSE,0,0) 'close rc-window
         End
   End Select
Loop

Sub play(vidFile As String)
   rc("clear") 'clear playlist
   rc("add " + vidFile) 'add new video to playlist
   rc("play") 'start play
End Sub

Sub rc(order As String)
   Dim As Integer x
   Dim As String b
   
   b = order + Chr(13) 'add RETURN
   For x = 0 To Len(b) - 1 'send order as simulated keystrokes to rc-window
      PostMessage(hWndRC,WM_CHAR,Cast(WPARAM,b[x]),0)
      Sleep 1
   Next
End Sub


Regards
grindstone
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: Best video file format?

Postby grindstone » Jul 31, 2015 9:29

Tourist Trap wrote:Maybe usage of an other function like AtlAxGetControl ?
I've tried it, but I failed.
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: Best video file format?

Postby Tourist Trap » Jul 31, 2015 9:33

grindstone wrote:This way you can embedd VLC-player to your programme:[code]#Include "windows.bi"

It doesnt work here. Console is just dragged at top left corner of the screen then nothing happens.
grindstone wrote:
Tourist Trap wrote:Maybe usage of an other function like AtlAxGetControl ?
I've tried it, but I failed.

It seems to have been possible to make the whole thing work from the libertybasic framework if I've well understood. If so, it should be also possible here since it's basically the same issue, make an ocx control work via the atl. For the calendar it seems ok.
grindstone
Posts: 726
Joined: May 05, 2015 5:35
Location: Germany

Re: Best video file format?

Postby grindstone » Jul 31, 2015 9:43

Have you set the path of the 'CreateProcess...' - statement to your VLC directory?
D.J.Peters
Posts: 8027
Joined: May 28, 2005 3:28
Contact:

Re: Best video file format?

Postby D.J.Peters » Jul 31, 2015 9:47

datwill310 wrote:... what format of video is the best to use for programming a game ...
xvid = MPG4

Joshy
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: Best video file format?

Postby Tourist Trap » Jul 31, 2015 9:48

grindstone wrote:Have you set the path of the 'CreateProcess...' - statement to your VLC directory?

Ok. Maybe the placement is not ideal but that works. Only one thing maybe . IF terminating vlc directly, the console will hang up.

Do you know a way to hide the interface from the command line?

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 3 guests