public async Task <IDirective> RenderAudioDocumentDirectiveAsync(Properties <string> properties) { var dataSourceTemplate = new DataSourceTemplate(); dataSourceTemplate.Add(properties); return(await Task.FromResult(new AplaRenderDocumentDirective() { token = "AplAudio", document = new Alexa.Presentation.APLA.Document() { mainTemplate = new MainTemplate() { parameters = new List <string>() { "payload" }, item = new Mixer() { items = new List <AudioBaseComponent>() { new Speech() { content = "<speak>${payload.templateData.properties.value}</speak>" }, new Audio() { source = "${payload.templateData.properties.audioUrl}" } } } } }, datasources = new DataSource() { templateData = await dataSourceTemplate.BuildTemplateData() },//await dataSource.Build("templateData") })); }
public async Task <IDirective> RenderVisualDocumentDirectiveAsync <T>(Properties <T> properties, IAlexaSession session) where T : class { var sourcesTemplate = new SourcesTemplate(); //Button click effect sourcesTemplate.Add("buttonPressEffectApla", new Alexa.Presentation.APLA.Document() { mainTemplate = new MainTemplate() { parameters = new List <string>() { "payload" }, item = new Audio() { source = "soundbank://soundlibrary/camera/camera_15", filter = new List <IFilter>() { new Volume() { amount = 0.2 } } } } }); var dataSourceTemplate = new DataSourceTemplate(); dataSourceTemplate.Add(properties); switch (properties?.documentType) { case RenderDocumentType.MEDIA_ITEM_DETAILS_TEMPLATE: dataSourceTemplate.Add(new TextToSpeechTransformer() { inputPath = "item.overview", outputName = "readOverview" }); dataSourceTemplate.Add(new AplaSpeechTransformer() { template = "buttonPressEffectApla", outputName = "buttonPressEffect" }); break; case RenderDocumentType.MEDIA_ITEM_LIST_SEQUENCE_TEMPLATE: dataSourceTemplate.Add(new AplaSpeechTransformer() { template = "buttonPressEffectApla", outputName = "buttonPressEffect" }); break; case RenderDocumentType.HELP_TEMPLATE: dataSourceTemplate.Add(new TextToSpeechTransformer() { inputPath = "values[*].value", outputName = "helpPhrase" }); break; case RenderDocumentType.GENERIC_VIEW_TEMPLATE: break; case RenderDocumentType.ROOM_SELECTION_TEMPLATE: break; default: return(null); } return(await Task.FromResult(new AplRenderDocumentDirective() { token = properties.documentType.ToString(), // ReSharper disable once RedundantNameQualifier document = new Alexa.Presentation.APL.Document() { theme = "${payload.templateData.properties.theme}", extensions = ExtensionsManager.RenderExtensionsList(session.context), settings = SettingsManager.RenderSettings(session.context), import = ImportsManager.RenderImportsList, resources = ResourcesManager.RenderResourcesList, graphics = VectorGraphicsManager.RenderVectorGraphicsDictionary, commands = new Dictionary <string, ICommand>() { { nameof(Animations.ScaleInOutOnPress), await Animations.ScaleInOutOnPress() }, { nameof(Animations.FadeIn), await Animations.FadeIn() }, { "ShakesHead", new PlayNamedChoreo() { name = Choreo.MixedExpressiveShakes } } }, mainTemplate = new MainTemplate() { parameters = new List <string>() { "payload" }, items = await Layouts.RenderLayoutComponents(properties, session) } }, datasources = new DataSource() { templateData = await dataSourceTemplate.BuildTemplateData() }, sources = await sourcesTemplate.BuildSources() })); }