From 6c7a2abca04a1c126255af6e8ad9a8b2f8f3d81c Mon Sep 17 00:00:00 2001 From: Tobias Viehweger Date: Thu, 29 Dec 2016 17:35:38 +0100 Subject: [PATCH] Add support for AudioPlay.Play directive --- Alexa.NET/Response/Directive/AudioItem.cs | 11 +++++++++ .../Response/Directive/AudioItemStream.cs | 23 +++++++++++++++++++ .../Directive/AudioPlayerPlayDirective.cs | 20 ++++++++++++++++ Alexa.NET/Response/Directive/PlayBehavior.cs | 18 +++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 Alexa.NET/Response/Directive/AudioItem.cs create mode 100644 Alexa.NET/Response/Directive/AudioItemStream.cs create mode 100644 Alexa.NET/Response/Directive/AudioPlayerPlayDirective.cs create mode 100644 Alexa.NET/Response/Directive/PlayBehavior.cs diff --git a/Alexa.NET/Response/Directive/AudioItem.cs b/Alexa.NET/Response/Directive/AudioItem.cs new file mode 100644 index 0000000..c222acc --- /dev/null +++ b/Alexa.NET/Response/Directive/AudioItem.cs @@ -0,0 +1,11 @@ +using Newtonsoft.Json; + +namespace Alexa.NET.Response.Directive +{ + public class AudioItem + { + [JsonRequired] + [JsonProperty("stream")] + public AudioItemStream Stream { get; set; } + } +} diff --git a/Alexa.NET/Response/Directive/AudioItemStream.cs b/Alexa.NET/Response/Directive/AudioItemStream.cs new file mode 100644 index 0000000..71c6dc9 --- /dev/null +++ b/Alexa.NET/Response/Directive/AudioItemStream.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; + +namespace Alexa.NET.Response.Directive +{ + public class AudioItemStream + { + [JsonRequired] + [JsonProperty("url")] + public string Url { get; set; } + + [JsonRequired] + [JsonProperty("token")] + public string Token { get; set; } + + [JsonRequired] + [JsonProperty("expectedPreviousToken")] + public string ExpectedPreviousToken { get; set; } + + [JsonRequired] + [JsonProperty("offsetInMilliseconds")] + public int OffsetInMilliseconds { get; set; } + } +} diff --git a/Alexa.NET/Response/Directive/AudioPlayerPlayDirective.cs b/Alexa.NET/Response/Directive/AudioPlayerPlayDirective.cs new file mode 100644 index 0000000..c5d08f1 --- /dev/null +++ b/Alexa.NET/Response/Directive/AudioPlayerPlayDirective.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Alexa.NET.Response.Directive +{ + public class AudioPlayerDirective : IDirective + { + [JsonProperty("playBehavior")] + [JsonRequired] + [JsonConverter(typeof(StringEnumConverter))] + public PlayBehavior PlayBehavior { get; set; } + + [JsonProperty("audioItem")] + [JsonRequired] + public AudioItem AudioPlayerAudioItem { get; set; } + + [JsonProperty("type")] + public string Type => "AudioPlayer.Play"; + } +} diff --git a/Alexa.NET/Response/Directive/PlayBehavior.cs b/Alexa.NET/Response/Directive/PlayBehavior.cs new file mode 100644 index 0000000..8b40629 --- /dev/null +++ b/Alexa.NET/Response/Directive/PlayBehavior.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Threading.Tasks; + +namespace Alexa.NET.Response.Directive +{ + public enum PlayBehavior + { + [EnumMember(Value = "REPLACE_ALL")] + ReplaceAll, + [EnumMember(Value = "ENQUEUE")] + Enqueue, + [EnumMember(Value = "REPLACE_ENQUEUED")] + ReplaceEnqueued + } +}