如何在 Alexa 中循环音频

编程入门 行业动态 更新时间:2024-10-05 23:22:12
本文介绍了如何在 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 解决了这个问题:www.amazon/Arif-Gebhardt-Rainmaker/dp/B079V11ZDM

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

诀窍是处理 PlaybackNearlyFinished 事件.developer.amazon/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 指令的标记从十开始倒计时.一旦计数器归零,就不要将另一个音频加入队列.但一定要在这种情况下做出回应,即使这只是一个空洞的回应.否则会出现超时错误等.

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 中循环音频

本文发布于:2023-11-28 03:15:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640750.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:音频   如何在   Alexa

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!