Code: Alles auswählen
; ------------------------------------------------------------
; http://www.purebasic.fr/english/viewtopic.php?f=12&t=65366
Global *mem
; ------------------------------------------------------------
;Don't forget, the wav is already loaded in memory (ReadData()).
Global *mm_Data, mm_size.l, mm_4.l, mm_opn
; Declare P_mm_IO(*lpM.MMIOINFO,mesg.l,param1.l,param2.l)
;
; ------------------------------------------------------------
;
; PureBasic - Movie example file
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
Procedure P_mm_IO(*lpM.MMIOINFO,mesg.l,lParam1.l,lParam2.l)
Select mesg
Case #MMIOM_OPEN
If mm_opn=1: ProcedureReturn 0: EndIf
mm_opn=1
*lpM\lDiskOffset = 0:ProcedureReturn 0
Case #MMIOM_CLOSE: ProcedureReturn 0
Case #MMIOM_READ
; CallDebugger
; Debug *mm_Data+*lpM\lDiskOffset
; Debug lParam1
; Debug lParam2
CopyMemory(*mm_Data+*lpM\lDiskOffset,lParam1, lParam2)
*lpM\lDiskOffset + lParam2;
ProcedureReturn lParam2
Case #MMIOM_SEEK
Select lParam2
Case #SEEK_SET
*lpM\lDiskOffset = lParam1
Case #SEEK_CUR
*lpM\lDiskOffset + lParam1
Case #SEEK_END
*lpM\lDiskOffset = fileSize - 1 - lParam1;
EndSelect
ProcedureReturn *lpM\lDiskOffset;
Default
ProcedureReturn -1
EndSelect
ProcedureReturn
EndProcedure
; ------------------------------------------------------------
Procedure PlayVideoFromRam (*mem, hw1, memsize = #PB_Ignore)
*generic_bank=AllocateMemory(4096)
*mm_Data = *mem
If memsize = #PB_Ignore
mm_size = MemorySize(*mm_Data)
; mm_size = ?ExitProc - ?Inc
EndIf
; OpenFile(0, "J:\_temp\decoded.mov")
; WriteData(0, *mm_Data, mm_size)
; CloseFile(0)
mm_4.l=mmioStringToFOURCC_("MOV",#MMIO_TOUPPER)
;could be anything other than "ABC", but not more than 3.
mm_opn=0
;Now the private IOroutine is being loaded:
mmioInstallIOProc_(mm_4,@P_mm_IO(),#MMIO_INSTALLPROC)
;Now an almost normal mci open command: but note the 'filename':
;..it's the extension "ABC+" which makes mci to use your private
;..routine P_mm_IO() for IO with wav at memory address *mm_Data:
uu.l=mciSendString_("open film.ABC+ type AVIVideo alias test",0,0,0)
uu.l=mciSendString_("window test handle " + Str(hw1),0,0,0) ; Put Film in Purebasic Windows
;uu.l=mciSendString_("put test destination at 0 0 "+Str(width/2)+" "+Str(height/2),0,0,0) ; show the film in a Part of the Windows
;from here on, you do mci commands (play [from], pause, status,..) as usual!
;...
;...
;when finished, close this way:
mciSendString_("play test",0,0,0)
;mciSendString_("play test fullscreen",0,0,0) ; <- fullscreenmode
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
Until Quit = 1
mciSendString_("close test",0,0,0)
mmioInstallIOProc_(mm_4,#Null,#MMIO_REMOVEPROC)
FreeMemory (*generic_bank)
EndProcedure
; ------------------------------------------------------------
If InitMovie() = 0
MessageRequester("Error", "Can't initialize movie playback !", 0)
End
EndIf
; ------------------------------------------------------------
; MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie files|*.avi;*.mpg|All Files|*.*", 0)
MovieName$ = "D:\Eigene Videos\Hier sind meine Videos\Ahsampo\VID_20210526_162108 - Kopie.mp4"
; ------------------------------------------------------------
file.s = "D:\Eigene Videos\Open Camera 2.avi"
; ------------------------------------------------------------
If OpenFile(0, file)
*mem = AllocateMemory(Lof(0))
ReadData(0, *mem, Lof(0))
CloseFile(0)
EndIf
; ------------------------------------------------------------
; OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0), "PureBasic - Movie")
OpenWindow(0, 100, 150, 400,500, "PureBasic - Movie")
; PlayMovie(*mem, WindowID(0))
; ------------------------------------------------------------
PlayVideoFromRam(*mem, WindowID(0))
; ------------------------------------------------------------
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DataSection
Inc:
IncludeBinary "D:\Eigene Videos\Open Camera 2.avi"
ExitProc:
EndDataSection