Skip to content

AudioPlayer

Outgoing Messages

PlayerActivityChanged

Notifies the platform implementation of a change in audio playback state.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Publish",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "PlayerActivityChanged"
        }
    },
    "payload": {
        "state": {{PlayerActivity}}        
    }
}

Payload

Property Type Required Description Example
state PlayerActivity Yes The new playback state.

GetPlayerPositionReply

Reply for GetPlayerPosition message.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Reply",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "GetPlayerPosition",
            "replyToId": {{String}}        
        }
    },
    "payload": {
        "playbackPosition": {{Int}}        
    }
}

Payload

Property Type Required Description Example
playbackPosition Int Yes The audio player's playback position in milliseconds.

GetPlayerDurationReply

Reply for GetPlayerDuration message.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Reply",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "GetPlayerDuration",
            "replyToId": {{String}}        
        }
    },
    "payload": {
        "playbackDuration": {{Int}}        
    }
}

Payload

Property Type Required Description Example
playbackDuration Int Yes The audio player's playback duration in milliseconds.

Incoming Messages

GetPlayerPosition

Returns the current playback position of the audio player.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Publish",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "GetPlayerPosition"
        }
    }
}

GetPlayerDuration

Returns the playback duration of the audio player.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Publish",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "GetPlayerDuration"
        }
    }
}

SetAsForegroundActivity

Sets the Alexa AudioPlayer interface as the foreground player the user sees on screen. This message is useful for scenarios in which the user played an AudioPlayer media source, then played a different Alexa-aware ExternalMediaPlayer media source, such as a deep-linked media app or a local media source, and then manually returned visual activity to the Alexa AudioPlayer GUI. This message ensures the next VUI command or GUI interaction with the playback control buttons acts on the AudioPlayer source rather than the more recently played ExternalMediaPlayer source.

Note: The AudioPlayer had to be previously playing at least once during this Engine cycle in order for this message to make Alexa act on AudioPlayer.

JSON Structure

{
    "header": {
        "version": "4.0",
        "messageType": "Publish",
        "id": {{String}},
        "messageDescription": {
            "topic": "AudioPlayer",
            "action": "SetAsForegroundActivity"
        }
    }
}

Enums

PlayerActivity

Values

Value Description
"IDLE" Audio playback has not yet begun.
"PLAYING" Audio is currently playing.
"STOPPED" Audio playback is stopped, either from a stop directive or playback error.
"PAUSED" Audio playback is paused.
"BUFFER_UNDERRUN" Audio playback is stalled because a buffer underrun has occurred.
"FINISHED" Audio playback is finished.