Added video support, still need to fix some things

This commit is contained in:
Stephan Sundermann committed 2012-03-05 18:51:23 +01:00
1 parent 7ae34d6c08
commit 01ec1b0927
2 files changed
+75 -5

No files matched your search

+70 -3
View File
@@ -26,8 +26,10 @@ namespace Vocaluxe.Base
private static bool _OwnMusicAdded; private static bool _OwnMusicAdded;
private static bool _BackgroundMusicAdded; private static bool _BackgroundMusicAdded;
private static bool _Playing; private static bool _Playing;
private static bool _VideoEnabled;
private static int _Video; private static int _Video = -1;
private static STexture _CurrentVideoTexture = new STexture(-1);
public static void Init() public static void Init()
{ {
@@ -63,12 +65,16 @@ namespace Vocaluxe.Base
} }
else else
Next(); Next();
if (_VideoEnabled)
LoadVideo();
} }
} }
} }
public static void Stop() public static void Stop()
{ {
if (_Video != 0)
CVideo.VdClose(_Video);
CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); CSound.FadeAndStop(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
_CurrentPlaylistElement = new PlaylistElement(); _CurrentPlaylistElement = new PlaylistElement();
@@ -77,6 +83,8 @@ namespace Vocaluxe.Base
public static void Pause() public static void Pause()
{ {
if (_Video != 0)
CVideo.VdPause(_Video);
CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime); CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
_Playing = false; _Playing = false;
} }
@@ -275,8 +283,37 @@ namespace Vocaluxe.Base
public static void ToggleVideo() public static void ToggleVideo()
{ {
_Video = CVideo.VdLoad(_CurrentPlaylistElement.GetVideoFilePath()); if (_Video != -1)
CVideo.VdSkip(_Video, CSound.GetLength(_CurrentMusicStream) / 4f, _CurrentPlaylistElement.GetVideoGap()); {
if (_VideoEnabled)
{
_VideoEnabled = false;
CVideo.VdClose(_Video);
_Video = -1;
CDraw.RemoveTexture(ref _CurrentVideoTexture);
return;
}
if (CVideo.VdFinished(_Video))
{
CVideo.VdClose(_Video);
CDraw.RemoveTexture(ref _CurrentVideoTexture);
_Video = -1;
return;
}
}
else
LoadVideo();
}
public static STexture UploadNewFrame()
{
if (_Video != -1)
{
float vtime = 0f;
CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime);
return _CurrentVideoTexture;
}
return _CurrentVideoTexture;
} }
public static int GetSongNr() public static int GetSongNr()
@@ -284,11 +321,26 @@ namespace Vocaluxe.Base
return _CurrentPlaylistElement.GetSongNr(); return _CurrentPlaylistElement.GetSongNr();
} }
public static EAspect GetVideoAspect()
{
return _CurrentPlaylistElement.GetVideoAspect();
}
public static bool IsDuet() public static bool IsDuet()
{ {
return _CurrentPlaylistElement.IsDuet(); return _CurrentPlaylistElement.IsDuet();
} }
public static bool IsVideoEnabled()
{
return _VideoEnabled;
}
public static bool HasVideo()
{
return File.Exists(_CurrentPlaylistElement.GetVideoFilePath());
}
private static bool IsBackgroundFile(PlaylistElement element) private static bool IsBackgroundFile(PlaylistElement element)
{ {
foreach (PlaylistElement elements in _BGMusicFileNames) foreach (PlaylistElement elements in _BGMusicFileNames)
@@ -298,6 +350,14 @@ namespace Vocaluxe.Base
} }
return false; return false;
} }
private static void LoadVideo()
{
CVideo.VdClose(_Video);
_Video = CVideo.VdLoad(_CurrentPlaylistElement.GetVideoFilePath());
CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream), _CurrentPlaylistElement.GetVideoGap());
_VideoEnabled = true;
}
} }
} }
@@ -311,6 +371,7 @@ class PlaylistElement
float _VideoGap; float _VideoGap;
int _SongNr; int _SongNr;
bool _Duet; bool _Duet;
EAspect _VideoAspect;
public PlaylistElement(CSong song) public PlaylistElement(CSong song)
{ {
@@ -322,6 +383,7 @@ class PlaylistElement
_VideoGap = song.VideoGap; _VideoGap = song.VideoGap;
_SongNr = song.ID; _SongNr = song.ID;
_Duet = song.IsDuet; _Duet = song.IsDuet;
_VideoAspect = song.VideoAspect;
} }
public PlaylistElement(string FilePath) public PlaylistElement(string FilePath)
@@ -379,6 +441,11 @@ class PlaylistElement
return _SongNr; return _SongNr;
} }
public EAspect GetVideoAspect()
{
return _VideoAspect;
}
public bool IsDuet() public bool IsDuet()
{ {
return _Duet; return _Duet;
@@ -136,7 +136,11 @@ namespace Vocaluxe.Screens
Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying(); Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying();
Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying(); Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying();
Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle(); Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle();
Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); if(CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.HasVideo())
Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.UploadNewFrame();
else
Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover();
return true; return true;
} }
@@ -150,7 +154,6 @@ namespace Vocaluxe.Screens
{ {
if (!_Active) if (!_Active)
return false; return false;
return base.Draw(); return base.Draw();
} }