Uh oh! We couldn’t find any match.

Please try other search keywords.

Bixby Developer Center

Guides

Audio

The example.audio sample capsule demonstrates how to play audio files in your capsule by importing the bixby.audioPlayer library capsule:

...
capsule-imports {
import (bixby.audioPlayer) {
version (0.3.1)
as (audioPlayer)
}
}
...

Download Capsule

In order to support playing audio in your capsule:

  1. Build an AudioInfo model, which handles the streaming information for the client audio player as well as other meta-data related to the audio clip you want to play
  2. Use a computed-input to pass the audioInfo model to the client audio player

This sample capsule shows how to do these steps.

Build an AudioInfo Model

The AudioInfo model is the primary concept model of the bixby.audioPlayer library capsule. It contains the AudioItem model, which the Bixby Audio Player actually streams, as well as additional inputs that are required to play the audio.

In the sample capsule, the BuildMeowAudioInfo action model creates this AudioInfo by outputting audioPlayer.AudioInfo.

action (BuildMeowAudioInfo) {
type (Search)
description (Makes a meow info to play.)
output (audioPlayer.AudioInfo)
}

The corresponding JavaScript file actually structures a specific input object, which specifies a category, displayName, and repeatMode. Additionally, there is an array of audioItem objects, which contain information about each audio file to be streamed. Here is an example audioItem:

 {
id: 1,
stream: [
{
url: "https://storage.googleapis.com/bixby-audio-player-example/meows/203121_777645-lq.mp3",
format: "mp3"
}
],
title: "Cat-ch Phrase",
subtitle: "Meow.",
artist: "Cool Cat",
albumName: "Catatonic",
albumArtUrl: "https://storage.googleapis.com/bixby-audio-player-example/meows/cat-08.jpg"
}

All these properties together create an AudioInfo object that can be returned for the client audio player.

Pass the AudioInfo Model

After an AudioInfo structure is created, this needs to be passed back to the client, so that the clip can be played. This is done in the PlayMeow action. This action collects a meowToPlay input from a user, builds an AudioInfo item with BuildMeowAudioInfo, and sends it to the audio player using a computed-input:

...
computed-input (meow) {
description (By passing in the AudioInfo object to the PlayAudio action, we ask the client to play our sound.)
type (audioPlayer.Result)
compute {
intent {
goal: audioPlayer.PlayAudio
value: $expr(meowToPlay)
}
}
hidden
}
...

The PlayMeow action is basically a specialized action to get the AudioInfo by invoking BuildMeowAudioInfo and then passing it back to the client in the computed-input as part of the PlayAudio action in the bixby.audio library capsule.

Testing This Sample Capsule

This sample capsule relies on native client apps being installed on the phone. Currently, Bixby Developer Studio will not actually invoke the client audio player to play the audio. As such, we recommend you test any capsule using the bixby.audioPlayer library with on-device testing, if possible.

Note

Because you cannot submit a capsule with the example namespace, in order to test a sample capsule on a device, you must change the id in the capsule.bxb file from example to your organization's before making a private submission.

For example, if your namespace is acme, change example.audio to acme.audio.