Ways in which I can embed a video player into GFX window?

Game development specific discussions.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Ways in which I can embed a video player into GFX window?

Post by srvaldez »

have looked in the inc/vlc folder ?
or perhaps you don't have the library ?
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Ways in which I can embed a video player into GFX window?

Post by dodicat »

You could try the built in mcisendstring in windows.

Code: Select all


#define WIN_INCLUDEALL
#include "Windows.bi"
#include "win/mmsystem.bi"
#Include once "/win/commctrl.bi"
#include "file.bi"
#define nul chr(0)


Screencontrol(103,"GDI")
Const k=.015

Declare Function SetWindowTheme Lib "UxTheme.dll" Alias "SetWindowTheme"(As Any Ptr,As zstring Ptr,As zstring Ptr) As Long

Dim Shared As String req: req="Media (.mpg) files"+NUL+"*.MPG"+NUL+"Others (.mp3,.mpeg, . . .)"+NUL+"*.MP3;*.MPEG"+NUL+"All files (*.*)"+NUL+"*.*"+NUL+NUL
Dim Shared As String message
Function map(a As Double,b As Double,_x_ As Double,c As Double,d As Double) As Double
  Return  (((d)-(c))*((_x_)-(a))/((b)-(a))+(c))
End Function

Function getfiles(filetypes As String) As String
  Dim As zstring * 2048 SELFILE
  Dim As String MYFILTER
  myfilter=filetypes
  Dim As OpenFileName SomeFile
  With SomeFile
    .lStructSize = Sizeof(OpenFileName)
    .hInstance = null
    .lpstrFilter = Strptr(MYFILTER)
    .lpstrFile = @SELFILE
    .nMaxFile = 2048
    .nMaxFileTitle = 0
    .lpstrTitle =@"Movies and songs"
    .Flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
  End With
  GetOpenFileName(@SomeFile)
  Return *SomeFile.lpstrFile
End Function

Function splice(s As String,a() As Long) As String
  Redim a(1 To 4)
  Dim As Long position=Instr(s," "),count=1
  a(1)= Val(s)
  While position>0
    count+=1
    a(count)= Val(Mid(s,position))
    position=Instr(position+1,s," ")
  Wend
  Return s
End Function

Function Getsize( file As String,Byref _Left As integer=0,Byref _Top As integer=0,Byref _Width As integer,Byref _Height As integer) As Long
  Dim As zstring * 50 mcidata
  Redim Elements() As Long
  mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
  Var MCIResult = mciSendString("Where file1 Destination max",@MCIData,50,0)
  If MCIResult = 0 Then
    splice(MCIData,elements())
    _Left = Elements(1)
    _Top = Elements(2)
    _Width = Elements(3)
    _Height = Elements(4)
    mciSendString("close file1", NULL, 0, 0)
  End If
  Return _width*_height
End Function

Function gethandle As hwnd 
  Static As Any Ptr win
  Screencontrol 2,Cast(Integer,win)
  Return win
End Function

Sub play(file As String="")
  If file="" Then file=getfiles(req)
  Dim As Integer x,y
  Screeninfo x,y
  If Screenptr =0 Then
    If Getsize(file,,,x,y) Then Screenres x,y
  End If
  Dim As Any Ptr  p=gethandle
  SetWindowTheme(p," "," ")
  Dim As zstring * 20 ans,length,position
  Windowtitle Mid(file,1+Instrrev(file,Any"\/"))+ "       p = pause, r = resume, s = restart, q = quit"
  mciSendString("open  " +Chr(34)+file+Chr(34)+ " type mpegvideo alias file1", NULL, 0, 0)
  mciSendString("window file1 handle " & p, 0, 0, 0)
  mcisendstring("put file1 destination at "+Str(Int(k*x))+" "+ Str(Int(k*y))+" "+ Str(Int(x-2*k*x))+" "+ Str(Int(y-8-2*k*y))+" ",0,0,0)
  mciSendString("play file1", NULL, 0,0)
  mciSendString("status file1 length",@length, 20,0)
  Dim As Long Lngth,pst
  Lngth=Vallng(length)
  Dim As Double t=Timer
  Dim As String key
  Do
    key=Inkey
    Select Case key
    Case "p"
      mciSendString("pause file1", NULL, 0,0)
    Case "r"
      mciSendString("play file1", NULL, 0,0)
    Case "s"
      mciSendString("play file1 from 0", NULL, 0,0)
    Case "q"
      mciSendString("close file1", NULL, 0, 0):End
    End Select
   
    mciSendString("status file1 position ",@position, 20,0)
    pst=Vallng(position)
    Var xpos=map(0,1,pst/Lngth,0,x)
    Line(0,y-4)-(xpos,y-4)
   
    mciSendString("status file1 mode ",@ans,20,0)
    message=ans
    If ans="stopped" Then Exit Sub
    Sleep 1
    If key=Chr(27) Then mciSendString("close file1", NULL, 0, 0):End
  Loop
End Sub

Sub done Destructor
  mciSendString("close file1", NULL, 0, 0)
End Sub

'===============================================
'=================  optional bit  ===========================
dim as string ans
print "do you want to set a screensize y/n"
print "y = yes,  n = no I shall use the default screen "
ans=input(1)
if lcase(ans)="y" then
    dim as string msg
    dim as long x,y
    dim as integer xres,yres
    screeninfo xres,yres  'desktop
    lbl:
    print msg
    print "maximum resolutions set to ";str(xres);",";str(yres)
    input "Enter your resolutions seperated by a comma e.g. 800,600  ",x,y
    if x=0 or y=0 then msg="please redo": goto lbl
    msg=""
    if x>xres or y>yres then msg= "Too big for monitor":goto lbl
    screenres x,y,32
    screencontrol 100,0,0 'optional screen otherwise mci screen
    
end if
'================================  ====================

dim as string filepath=""     'optional path otherwise openfile window
play(filepath)
Print message                  'optional end message
Sleep

  
PublioMaro_Virgilivs
Posts: 19
Joined: Nov 23, 2020 16:45
Contact:

Re: Ways in which I can embed a video player into GFX window?

Post by PublioMaro_Virgilivs »

srvaldez wrote:have looked in the inc/vlc folder ?
or perhaps you don't have the library ?
Now I see... But something is still wrong, I get a linking error code (exit code 1). And I don't see the log file.
PublioMaro_Virgilivs
Posts: 19
Joined: Nov 23, 2020 16:45
Contact:

Re: Ways in which I can embed a video player into GFX window?

Post by PublioMaro_Virgilivs »

dodicat wrote:You could try the built in mcisendstring in windows.

Code: Select all


#define WIN_INCLUDEALL
#include "Windows.bi"
...
  
Thanks a lot dodicat!!!
Post Reply