Fix missing song length and wrong volumes (int=0-100, float=0-1)

Also fade in preview music
This commit is contained in:
Flamefire committed 2014-11-27 23:06:01 +01:00
1 parent b99f9467de
commit 4a78dd4b31
17 files changed
+65 -73

No files matched your search

+2 -9
View File
@@ -133,14 +133,7 @@ namespace VocaluxeLib.Utils.Player
Load(file, position, autoplay);
}
public new void Play()
{
CBase.Sound.SetPosition(_StreamID, _StartPosition);
CBase.Video.Skip(_Video, _StartPosition, _Song.VideoGap);
TogglePause();
}
public new void Stop()
public override void Stop()
{
base.Stop();
@@ -150,7 +143,7 @@ namespace VocaluxeLib.Utils.Player
CBase.Video.Close(ref _Video);
}
public new void TogglePause()
public override void TogglePause()
{
if (IsPlaying && _Video != null)
{
+8 -13
View File
@@ -15,21 +15,16 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace VocaluxeLib.Utils.Player
{
public class CSoundPlayer
{
protected int _StreamID = -1;
protected float _Volume;
protected int _Volume = 100;
protected float _StartPosition;
protected float _FadeTime = CBase.Settings.GetSoundPlayerFadeTime();
protected readonly float _FadeTime = CBase.Settings.GetSoundPlayerFadeTime();
public float Volume
public int Volume
{
set
{
@@ -107,19 +102,19 @@ namespace VocaluxeLib.Utils.Player
return;
CBase.Sound.SetPosition(_StreamID, _StartPosition);
CBase.Sound.SetStreamVolume(_StreamID, 0f);
CBase.Sound.SetStreamVolume(_StreamID, 0);
CBase.Sound.Fade(_StreamID, Volume, _FadeTime);
CBase.Sound.Play(_StreamID);
IsPlaying = true;
}
public void TogglePause()
public virtual void TogglePause()
{
if (_StreamID == -1)
return;
if (IsPlaying)
CBase.Sound.Fade(_StreamID, 0f, _FadeTime, EStreamAction.Pause);
CBase.Sound.Fade(_StreamID, 0, _FadeTime, EStreamAction.Pause);
else
{
CBase.Sound.Fade(_StreamID, Volume, _FadeTime);
@@ -129,12 +124,12 @@ namespace VocaluxeLib.Utils.Player
IsPlaying = !IsPlaying;
}
public void Stop()
public virtual void Stop()
{
if (_StreamID == -1 || !IsPlaying)
return;
CBase.Sound.Fade(_StreamID, 0f, _FadeTime, EStreamAction.Close);
CBase.Sound.Fade(_StreamID, 0, _FadeTime, EStreamAction.Close);
_StreamID = -1;
IsPlaying = false;