From 2907b7d4f1f6563229a829f7d47d4a9b588d8f2e Mon Sep 17 00:00:00 2001 From: Tobias Viehweger Date: Fri, 30 Dec 2016 16:30:44 +0100 Subject: [PATCH] Add builder methods for AudioPlayerPlay --- Alexa.NET/ResponseBuilder.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Alexa.NET/ResponseBuilder.cs b/Alexa.NET/ResponseBuilder.cs index 071c56f..d31b2be 100644 --- a/Alexa.NET/ResponseBuilder.cs +++ b/Alexa.NET/ResponseBuilder.cs @@ -1,5 +1,6 @@ using Alexa.NET.Request; using Alexa.NET.Response; +using Alexa.NET.Response.Directive; using System; using System.Collections.Generic; using System.Linq; @@ -63,6 +64,37 @@ public static SkillResponse Ask(IOutputSpeech speechResponse, Reprompt reprompt, return BuildResponse(speechResponse, false, sessionAttributes, reprompt, null); } + public static SkillResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token) + { + return AudioPlayerPlay(playBehavior, url, token, 0); + } + + public static SkillResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token, int offsetInMilliseconds) + { + return AudioPlayerPlay(playBehavior, url, token, null, offsetInMilliseconds); + } + + public static SkillResponse AudioPlayerPlay(PlayBehavior playBehavior, string url, string token, string expectedPreviousToken, int offsetInMilliseconds) + { + var response = BuildResponse(null, true, null, null, null); + response.Response.Directives.Add(new AudioPlayerPlayDirective() + { + PlayBehavior = playBehavior, + AudioItem = new AudioItem() + { + Stream = new AudioItemStream() + { + Url = url, + Token = token, + ExpectedPreviousToken = expectedPreviousToken, + OffsetInMilliseconds = offsetInMilliseconds + } + } + }); + + return response; + } + private static SkillResponse BuildResponse(IOutputSpeech outputSpeech, bool shouldEndSession, Session sessionAttributes, Reprompt reprompt, ICard card) { SkillResponse response = new Response.SkillResponse();