Merged branch master into 71

This commit is contained in:
Master Kwoth
2016-02-05 15:59:55 +01:00
7 changed files with 124 additions and 70 deletions

View File

@@ -88,12 +88,13 @@ namespace NadekoBot.Classes.Music {
MusicModule.musicPlayers.TryRemove(_e.Server, out throwAwayValue);
}
public void SetVolume(int value) {
public int SetVolume(int value) {
if (value < 0)
value = 0;
if (value > 150)
value = 150;
this.Volume = value/100f;
return value;
}
internal bool TogglePause() => IsPaused = !IsPaused;

View File

@@ -38,9 +38,11 @@ namespace NadekoBot.Classes.Music {
public float Volume => MusicControls?.Volume ?? 1.0f;
public bool RadioLink { get; private set; }
public MusicControls MusicControls;
public StreamRequest(CommandEventArgs e, string query, MusicControls mc) {
public StreamRequest(CommandEventArgs e, string query, MusicControls mc, bool radio = false) {
if (e == null)
throw new ArgumentNullException(nameof(e));
if (query == null)
@@ -48,6 +50,7 @@ namespace NadekoBot.Classes.Music {
this.MusicControls = mc;
this.Server = e.Server;
this.Query = query;
this.RadioLink = radio;
Task.Run(() => ResolveStreamLink());
mc.SongQueue.Add(this);
}
@@ -55,8 +58,13 @@ namespace NadekoBot.Classes.Music {
private async void ResolveStreamLink() {
string uri = null;
try {
if (SoundCloud.Default.IsSoundCloudLink(Query)) {
if (RadioLink) {
uri = Query;
Title = $"Radio Stream - <{Query}>";
}
else if (SoundCloud.Default.IsSoundCloudLink(Query)) {
if (OnResolving != null)
OnResolving();
var svideo = await SoundCloud.Default.GetVideoAsync(Query);
Title = svideo.FullName + " - SoundCloud";
uri = svideo.StreamLink;