diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-04-21 18:27:36 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-04-21 18:27:36 +0000 |
commit | 868ce765441473e7d1fec9b3ad22a707f121a637 (patch) | |
tree | 8f67a0e6ff2c306603ef37ec0bc8cc0e042eb5d2 /src/menu | |
parent | 62c665cb863914c2d5e07bf4b8bd07c1c45be7ac (diff) | |
download | usdx-868ce765441473e7d1fec9b3ad22a707f121a637.tar.gz usdx-868ce765441473e7d1fec9b3ad22a707f121a637.tar.xz usdx-868ce765441473e7d1fec9b3ad22a707f121a637.zip |
- add video loop option
- allow multiple instances of a video
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2260 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/menu')
-rw-r--r-- | src/menu/UMenuBackgroundVideo.pas | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/menu/UMenuBackgroundVideo.pas b/src/menu/UMenuBackgroundVideo.pas index 9d265764..006c45e0 100644 --- a/src/menu/UMenuBackgroundVideo.pas +++ b/src/menu/UMenuBackgroundVideo.pas @@ -36,6 +36,7 @@ interface uses UThemes, UMenuBackground, + UMusic, UVideo, UPath; @@ -84,6 +85,7 @@ type } TMenuBackgroundVideo = class (TMenuBackground) private fFilename: IPath; + fBgVideo: IVideo; public constructor Create(const ThemedSettings: TThemeBackground); override; procedure OnShow; override; @@ -102,7 +104,6 @@ implementation uses gl, glext, - UMusic, SysUtils, UTime, USkins, @@ -116,42 +117,48 @@ begin raise EMenuBackgroundError.Create('TMenuBackgroundVideo: No video filename present'); fFileName := Skin.GetTextureFileName(ThemedSettings.Tex); - if fFilename.IsFile and VideoPlayback.Open(fFileName) then - begin - VideoBGTimer.SetTime(0); - VideoPlayback.Play; - end - else + if (not fFilename.IsFile) then raise EMenuBackgroundError.Create('TMenuBackgroundVideo: Can''t load background video: ' + fFilename.ToNative); end; destructor TMenuBackgroundVideo.Destroy; begin - end; -procedure TMenuBackgroundVideo.OnShow; +procedure TMenuBackgroundVideo.OnShow; begin - if VideoPlayback.Open( fFileName ) then + fBgVideo := VideoPlayback.Open(fFileName); + if (fBgVideo <> nil) then begin VideoBGTimer.SetTime(0); - VideoPlayback.Play; + fBgVideo.Loop := true; + fBgVideo.Play; end; end; procedure TMenuBackgroundVideo.OnFinish; begin - + // unload video + fBgVideo := nil; end; -procedure TMenuBackgroundVideo.Draw; +procedure TMenuBackgroundVideo.Draw; begin - If (ScreenAct = 1) then //Clear just once when in dual screen mode + // clear just once when in dual screen mode + if (ScreenAct = 1) then + begin glClear(GL_DEPTH_BUFFER_BIT); + // video failure -> draw blank background + if (fBgVideo = nil) then + glClear(GL_COLOR_BUFFER_BIT); + end; - VideoPlayback.GetFrame(VideoBGTimer.GetTime()); + if (fBgVideo <> nil) then + begin + fBgVideo.GetFrame(VideoBGTimer.GetTime()); // FIXME: why do we draw on screen 2? Seems to be wrong. - VideoPlayback.DrawGL(2); + fBgVideo.DrawGL(2); + end; end; // Implementation of TBGVideo |