Increased performance

This commit is contained in:
Stephan Sundermann committed 2012-03-10 14:53:52 +01:00
1 parent b3ba1ff111
commit 9dfa3e0f0e
1 file changed
+61 -33
+61 -33
View File
@@ -412,119 +412,147 @@ namespace Vocaluxe.Base
class PlaylistElement class PlaylistElement
{ {
string _MusicFilePath; string _MusicFilePath;
int _SongNr; int _SongID;
public PlaylistElement(CSong song) public PlaylistElement(CSong song)
{ {
_MusicFilePath = string.Empty; _MusicFilePath = string.Empty;
_SongNr = song.ID; _SongID = song.ID;
} }
public PlaylistElement(string FilePath) public PlaylistElement(string FilePath)
{ {
_MusicFilePath = FilePath; _MusicFilePath = FilePath;
_SongNr = -1; _SongID = -1;
} }
public PlaylistElement() public PlaylistElement()
{ {
_MusicFilePath = string.Empty; _MusicFilePath = string.Empty;
_SongNr = -1; _SongID = -1;
} }
public string GetMusicFilePath() public string GetMusicFilePath()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).GetMP3(); CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.GetMP3();
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return _MusicFilePath; return _MusicFilePath;
} }
public string GetVideoFilePath() public string GetVideoFilePath()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).GetVideo(); CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.GetVideo();
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return string.Empty; return string.Empty;
} }
public string GetTitle() public string GetTitle()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).Title; CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.Title;
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return "Unknown"; return "Unknown";
} }
public string GetArtist() public string GetArtist()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).Artist; CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.Artist;
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return "Unknown"; return "Unknown";
} }
public STexture GetCover() public STexture GetCover()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).CoverTextureSmall; CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.CoverTextureSmall;
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return CCover.NoCover; return CCover.NoCover;
} }
public float GetVideoGap() public float GetVideoGap()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).VideoGap; CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.VideoGap;
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return 0; return 0;
} }
public int GetSongNr() public int GetSongNr()
{ {
return _SongNr; return _SongID;
} }
public bool IsDuet() public bool IsDuet()
{ {
if (_SongNr >= 0) if (_SongID >= 0)
if (CSongs.GetSong(_SongNr) != null) {
return CSongs.GetSong(_SongNr).IsDuet; CSong song;
song = CSongs.GetSong(_SongID);
if (song != null)
return song.IsDuet;
else else
{ {
_SongNr = -1; _SongID = -1;
CLog.LogError("Song not found"); CLog.LogError("Song not found");
} }
}
return false; return false;
} }
} }