如何在Alexa中循环播放音频 [英] How to loop audio in Alexa

查看:105
本文介绍了如何在Alexa中循环播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Alexa打造一种环境音频睡眠技能!我正在尝试循环播放音频,因此不必下载10小时版本的音频。如何使音频工作?我将其构建到可以播放音频的位置,但不能循环播放。

I am building a ambient audio skill for sleep for Alexa! I am trying to loop the audio so I don't have to download 10 hour versions of the audio. How do I get the audio to work? I have it build to where it will play the audio, but not loop.

推荐答案

我已经用我的技能Rainmaker解决了这个问题: https://www.amazon.com/Arif-Gebhardt-Rainmaker/dp/B079V11ZDM

I've solved this problem in my skill Rainmaker: https://www.amazon.com/Arif-Gebhardt-Rainmaker/dp/B079V11ZDM

技巧是处理 PlaybackNearlyFinished 事件。
https://developer.amazon。 com / de / docs / alexa-voice-service / audioplayer.html#playbacknearlyfinished

此事件在当前播放的音频流结束前不久触发。
使用行为为 ENQUEUE 的另一个 audioPlayerPlay 指令响应事件。这将无限循环您的音频,直到它被例如 AMAZON.StopIntent

This event is fired shortly before the currently playing audio stream is ending. Respond to the event with another audioPlayerPlay directive with behavior ENQUEUE. This will infinitely loop your audio until it gets interrupted by e.g. the AMAZON.StopIntent.

高级:如果您想进行有限循环,例如说十倍于音频,请使用 audioPlayerPlay 指令的标记从10开始递减计数。计数器归零后,就不用再排队其他音频了。但是在这种情况下,请务必做出回应,即使只是空洞的回应。否则,您将收到超时错误等。

Advanced: if you want a finite loop, say ten times your audio, use the token of the audioPlayerPlay directive to count down from ten. Once the counter hits zero, just don't enqueue another audio. But be sure to respond something in this case, even if it's just an empty response. Otherwise you will get a timeout error or the like.

这篇关于如何在Alexa中循环播放音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆