Skip to content

Commit

Permalink
Merge pull request timheuer#8 from matthiasxc/audio-skills-updates
Browse files Browse the repository at this point in the history
Additional AudioPlayer features
  • Loading branch information
timheuer authored Mar 9, 2017
2 parents 1585d38 + 927ab06 commit 1e8cb27
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Alexa.NET/Request/Type/AudioPlayerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,41 @@ public class AudioPlayerRequest: Request

[JsonProperty("currentPlaybackState")]
public PlaybackState CurrentPlaybackState { get; set; }

[JsonProperty("enqueuedToken")]
public string EnqueuedToken { get; set; }

public bool HasEnqueuedItem
{
get
{
if (EnqueuedToken != null && EnqueuedToken != "")
return true;
else
return false;
}
}

public AudioRequestType AudioRequestType
{
get
{
switch (this.Type.Split('.')[1])
{
case "PlaybackStarted":
return AudioRequestType.PlaybackStarted;
case "PlaybackFinished":
return AudioRequestType.PlaybackStarted;
case "PlaybackStopped":
return AudioRequestType.PlaybackStopped;
case "PlaybackNearlyFinished":
return AudioRequestType.PlaybackNearlyFinished;
case "PlaybackFailed":
return AudioRequestType.PlaybackFailed;
default:
return AudioRequestType.Unknown;
}
}
}
}
}
24 changes: 24 additions & 0 deletions Alexa.NET/Request/Type/AudioRequestType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;

namespace Alexa.NET.Request.Type
{
public enum AudioRequestType
{
[EnumMember(Value = "PlaybackStarted")]
PlaybackStarted,
[EnumMember(Value = "PlaybackFinished")]
PlaybackFinished,
[EnumMember(Value = "PlaybackStopped")]
PlaybackStopped,
[EnumMember(Value = "PlaybackNearlyFinished")]
PlaybackNearlyFinished,
[EnumMember(Value = "PlaybackFailed")]
PlaybackFailed,
[EnumMember(Value = "Unknown")]
Unknown
}
}
133 changes: 133 additions & 0 deletions Alexa.NET/Request/Type/BuiltInIntents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Alexa.NET.Request.Type
{

public class BuiltInIntent
{

/// <summary>
/// Purpose:
/// - Let the user cancel a transaction or task (but remain in the skill)
/// - Let the user completely exit the skill
///
/// Common Utterances: cancel, never mind, forget it
/// </summary>
public const string Cancel = "AMAZON.CancelIntent";

/// <summary>
/// Purpose:
/// Provide help about how to use the skill.
///
/// Common Utterances: help, help me, can you help me
/// </summary>
public const string Help = "AMAZON.HelpIntent";

/// <summary>
/// Purpose:
/// - Let the user stop an action (but remain in the skill)
/// - Let the user completely exit the skill
///
/// Common Utterances: stop, off, shut up
/// </summary>
public const string Stop = "AMAZON.StopIntent";

public const string Yes = "AMAZON.YesIntent";

public const string No = "AMAZON.NoIntent";

/// <summary>
/// Audio Intents
/// - These intents are for use with a skill that plays audio
/// </summary>
///

/// <summary>
/// Purpose:
/// - Lets user turn on or off an audio loop
/// - can be used without the skill invocation name (ie: "Alexa, loop on")
///
/// Common Utterances: loop off, loop on
/// </summary>
public const string LoopOff = "AMAZON.LoopOffIntent";

public const string LoopOn = "AMAZON.LoopOnIntent";

/// <summary>
/// Purpose:
/// - Lets user turn on or off shuffle mode, usually for audio skills that
/// stream a playlist of tracks
/// - can be used without the skill invocation name (ie: "Alexa, loop on")
///
/// Common Utterances: loop off, loop on
/// </summary>
public const string ShuffleOn = "AMAZON.ShuffleOnIntent";

public const string ShuffleOff = "AMAZON.ShuffleOffIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate to the next item in a list
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, next")
///
/// Common Utterances: next, skip, skip forward
/// </summary>
public const string Next = "AMAZON.NextIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate to the previous item in a list
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, go back")
///
/// Common Utterances: go back, skip back, back up
/// </summary>
public const string Previous = "AMAZON.PreviousIntent";

/// <summary>
/// Purpose:
/// - Let the user pause the action in progress (such as a game or audio track)
/// - MUST be implemented for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, pause")
///
/// Common Utterances: pause, pause that
/// </summary>
public const string Pause = "AMAZON.PauseIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate repeat the last action
/// - can be used without the skill invocation name (ie: "Alexa, repeat")
///
/// Common Utterances: repeat, say that again
/// </summary>
public const string Repeat = "AMAZON.RepeatIntent";

/// <summary>
/// Purpose:
/// - Let the user resume or continue an action
/// - MUST be implemented for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, resume ")
///
/// Common Utterances: resume, continue, keep going
/// </summary>
public const string Resume = "AMAZON.ResumeIntent";

/// <summary>
/// Purpose:
/// - Let the user to restart an action, such as restarting a game,
/// transaction, or audio track.
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, restart")
///
/// Common Utterances: start over, restart, start again
/// </summary>
public const string StartOver = "AMAZON.StartOverIntent";

}

}
16 changes: 16 additions & 0 deletions Alexa.NET/Response/Directive/ClearBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;

namespace Alexa.NET.Response.Directive
{
public enum ClearBehavior
{
[EnumMember(Value = "CLEAR_ENQUEUED")]
ClearEnqueued,
[EnumMember(Value = "CLEAR_ALL")]
ClearAll
}
}
20 changes: 20 additions & 0 deletions Alexa.NET/Response/Directive/ClearQueueDirective.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Alexa.NET.Response.Directive
{
public class ClearQueueDirective : IDirective
{
[JsonProperty("type")]
public string Type => "AudioPlayer.ClearQueue";

[JsonProperty("clearBehavior")]
[JsonRequired]
[JsonConverter(typeof(StringEnumConverter))]
public PlayBehavior ClearBehavior { get; set; }
}
}
14 changes: 12 additions & 2 deletions Alexa.NET/ResponseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ public static SkillResponse Tell(IOutputSpeech speechResponse)
{
return BuildResponse(speechResponse, true, null, null, null);
}
public static SkillResponse TellWithReprompt(IOutputSpeech speechResponse, Reprompt reprompt)
{
return BuildResponse(speechResponse, true, null, reprompt, null);
}


public static SkillResponse Tell(IOutputSpeech speechResponse, Session sessionAttributes)
{
return BuildResponse(speechResponse, true, sessionAttributes, null, null);
}

}

public static SkillResponse TellWithReprompt(IOutputSpeech speechResponse, Reprompt reprompt, Session sessionAttributes)
{
return BuildResponse(speechResponse, true, sessionAttributes, reprompt, null);
}

public static SkillResponse TellWithCard(IOutputSpeech speechResponse, string title, string content)
{
SimpleCard card = new SimpleCard();
Expand Down

0 comments on commit 1e8cb27

Please sign in to comment.