Apply R# clean-up for reliability (#877)
* Apply R# clean-up for reliability - Migrate to NUnit4 Assert.That - Update dependencise versions - Fix LangVersion to 9.0 (until net core migration) - Reformat code - Apply 'var' style (easier for refactoring) - Remove redundant parentheses - Add braces on every condition blocks (1 line) - Uses new null checking patterns - Uses AutoProperties when possible - Uses string scalar type instead of class - Clean usings - Add .orig files in git ignore - Rename some properties to respect defined conventions and US format definition - ID -> Id - BPM -> Bpm - Finish -> End * Update R# settings according to the clean-up made
This commit is contained in:
1 parent
b9b0f7c8df
commit
6ffa63b923
236 files changed
+14194
-7278
No files matched your search
@@ -35,25 +35,32 @@ namespace VocaluxeLib.Utils.Player
|
||||
set
|
||||
{
|
||||
if (_VideoEnabled == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_VideoEnabled = value;
|
||||
if (_VideoEnabled)
|
||||
{
|
||||
_LoadVideo();
|
||||
}
|
||||
else
|
||||
{
|
||||
_CloseVideo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int SongID
|
||||
public int SongId
|
||||
{
|
||||
get { return _Song == null ? -1 : _Song.ID; }
|
||||
get { return _Song == null ? -1 : _Song.Id; }
|
||||
}
|
||||
|
||||
public bool SongHasVideo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Song != null && !String.IsNullOrEmpty(_Song.Folder) && !String.IsNullOrEmpty(_Song.VideoFileName) &&
|
||||
return _Song != null && !string.IsNullOrEmpty(_Song.Folder) && !string.IsNullOrEmpty(_Song.VideoFileName) &&
|
||||
File.Exists(Path.Combine(_Song.Folder, _Song.VideoFileName));
|
||||
}
|
||||
}
|
||||
@@ -62,8 +69,11 @@ namespace VocaluxeLib.Utils.Player
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Song != null && !String.IsNullOrEmpty(_Song.Artist) && !String.IsNullOrEmpty(_Song.Title))
|
||||
if (_Song != null && !string.IsNullOrEmpty(_Song.Artist) && !string.IsNullOrEmpty(_Song.Title))
|
||||
{
|
||||
return _Song.Artist + " - " + _Song.Title;
|
||||
}
|
||||
|
||||
return base.ArtistAndTitle;
|
||||
}
|
||||
}
|
||||
@@ -73,30 +83,39 @@ namespace VocaluxeLib.Utils.Player
|
||||
get { return _Song == null ? CBase.Cover.GetNoCover() : _Song.CoverTextureBig; }
|
||||
}
|
||||
|
||||
public CSongPlayer(bool loop = false) : base(loop) {}
|
||||
public CSongPlayer(bool loop = false) : base(loop) { }
|
||||
|
||||
public CTextureRef GetVideoTexture()
|
||||
{
|
||||
if (_Video == null || _Song == null)
|
||||
{
|
||||
return null;
|
||||
if (CBase.Video.GetFrame(_Video, CBase.Sound.GetPosition(_StreamID)))
|
||||
}
|
||||
|
||||
if (CBase.Video.GetFrame(_Video, CBase.Sound.GetPosition(_StreamId)))
|
||||
{
|
||||
if (_VideoFading != null)
|
||||
{
|
||||
bool finished;
|
||||
_Video.Texture.Color.A = _VideoFading.GetValue(out finished);
|
||||
if (finished)
|
||||
{
|
||||
_VideoFading = null;
|
||||
}
|
||||
}
|
||||
|
||||
return _Video.Texture;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Load(CSong song, float position = 0f, bool autoplay = false)
|
||||
{
|
||||
if (song == null)
|
||||
{
|
||||
throw new ArgumentNullException("song");
|
||||
}
|
||||
|
||||
Load(song.GetMP3(), position, autoplay);
|
||||
_Song = song;
|
||||
@@ -106,15 +125,21 @@ namespace VocaluxeLib.Utils.Player
|
||||
private void _LoadVideo()
|
||||
{
|
||||
if (_Song == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_Video != null || !SongHasVideo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string videoFilePath = Path.Combine(_Song.Folder, _Song.VideoFileName);
|
||||
var videoFilePath = Path.Combine(_Song.Folder, _Song.VideoFileName);
|
||||
_Video = CBase.Video.Load(videoFilePath);
|
||||
if (_Video == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_VideoFading = new CFading(0f, 1f, 3f);
|
||||
|
||||
@@ -124,48 +149,64 @@ namespace VocaluxeLib.Utils.Player
|
||||
CBase.Video.Resume(_Video);
|
||||
}
|
||||
else
|
||||
{
|
||||
CBase.Video.Skip(_Video, 0f, _Song.VideoGap);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Play()
|
||||
{
|
||||
if (!base.Play())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_Video != null)
|
||||
{
|
||||
CBase.Video.Skip(_Video, Position, _Song.VideoGap);
|
||||
CBase.Video.Resume(_Video);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pause()
|
||||
{
|
||||
if (!base.Pause())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_Video != null)
|
||||
{
|
||||
CBase.Video.Pause(_Video);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Stop()
|
||||
{
|
||||
if (!base.Stop())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_Video != null)
|
||||
{
|
||||
CBase.Video.Pause(_Video);
|
||||
CBase.Video.Skip(_Video, 0f, _Song.VideoGap);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void _CloseVideo()
|
||||
{
|
||||
if (_Video != null)
|
||||
{
|
||||
CBase.Video.Close(ref _Video);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
@@ -176,4 +217,4 @@ namespace VocaluxeLib.Utils.Player
|
||||
_CloseVideo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user