-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for setting repeat mode on queue load
- Loading branch information
Showing
8 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Newtonsoft.Json; | ||
using Sharpcaster.Models.Media; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Sharpcaster.Converters | ||
{ | ||
public class RepeatModeEnumConverter : JsonConverter | ||
{ | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var repeatModeType = (RepeatModeType)value; | ||
switch (repeatModeType) | ||
{ | ||
case RepeatModeType.OFF: | ||
writer.WriteValue("REPEAT_OFF"); | ||
break; | ||
case RepeatModeType.ALL: | ||
writer.WriteValue("REPEAT_ALL"); | ||
break; | ||
case RepeatModeType.SINGLE: | ||
writer.WriteValue("REPEAT_SINGLE"); | ||
break; | ||
case RepeatModeType.ALL_AND_SHUFFLE: | ||
writer.WriteValue("REPEAT_ALL_AND_SHUFFLE"); | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException(); | ||
} | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
var enumString = (string)reader.Value; | ||
RepeatModeType? repeatModeType = null; | ||
|
||
switch (enumString) | ||
{ | ||
case "REPEAT_OFF": | ||
repeatModeType = RepeatModeType.OFF; | ||
break; | ||
case "REPEAT_ALL": | ||
repeatModeType = RepeatModeType.ALL; | ||
break; | ||
case "REPEAT_SINGLE": | ||
repeatModeType = RepeatModeType.SINGLE; | ||
break; | ||
case "REPEAT_ALL_AND_SHUFFLE": | ||
repeatModeType = RepeatModeType.ALL_AND_SHUFFLE; | ||
break; | ||
} | ||
return repeatModeType; | ||
} | ||
|
||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(string); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Sharpcaster.Models.Media | ||
{ | ||
public enum RepeatModeType | ||
{ | ||
OFF, | ||
ALL, | ||
SINGLE, | ||
ALL_AND_SHUFFLE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters