Alexa Auto SDK
4.3
|
Classes | |
struct | PlaybackContext |
Public Types | |
enum | MutedState { MutedState::MUTED, MutedState::UNMUTED } |
using | MediaState = aace::audio::AudioOutputEngineInterface::MediaState |
using | MediaError = aace::audio::AudioOutputEngineInterface::MediaError |
using | FocusAction = aace::audio::AudioOutputEngineInterface::FocusAction |
Public Member Functions | |
virtual bool | prepare (std::shared_ptr< AudioStream > stream, bool repeating)=0 |
virtual bool | prepare (const std::string &url, bool repeating, const PlaybackContext &playbackContext)=0 |
virtual void | mayDuck ()=0 |
virtual bool | play ()=0 |
virtual bool | stop ()=0 |
virtual bool | pause ()=0 |
virtual bool | resume ()=0 |
virtual bool | startDucking ()=0 |
virtual bool | stopDucking ()=0 |
virtual int64_t | getPosition ()=0 |
virtual bool | setPosition (int64_t position)=0 |
virtual int64_t | getDuration ()=0 |
virtual int64_t | getNumBytesBuffered () |
virtual bool | volumeChanged (float volume)=0 |
virtual bool | mutedStateChanged (MutedState state)=0 |
void | mediaStateChanged (MediaState state) |
void | mediaError (MediaError error, const std::string &description="") |
void | audioFocusEvent (FocusAction action) |
Static Public Attributes | |
static const int64_t | TIME_UNKNOWN = -1 |
AudioOutput should be extended to play audio data provided by the Engine.
After returning true
from a playback-controlling method invocation from the Engine (i.e. play()
, pause()
, stop()
, resume()
), it is required that platform implementation notify the Engine of a playback state change by calling one of mediaStateChanged()
with the new MediaState
or mediaError()
with the MediaError
. The Engine expects no call to mediaStateChanged()
in response to an invocation for which the platform returned false
.
The platform implementation may call mediaError()
or mediaStateChanged()
with MediaState::BUFFERING
at any time during a playback operation to notify the Engine of an error or buffer underrun, respectively. When the media player resumes playback after a buffer underrun, the platform implementation should call mediaStateChanged()
with MediaState::PLAYING
.
AudioOutput
platform implementation should be able to support the audio formats recommended by AVS for a familiar Alexa experience: https://developer.amazon.com/docs/alexa-voice-service/recommended-media-support.html using aace::audio::AudioOutput::MediaState = aace::audio::AudioOutputEngineInterface::MediaState |
Describes the playback state of the platform media player
aace::alexa::MediaPlayerEngineInterface::MediaState
using aace::audio::AudioOutput::MediaError = aace::audio::AudioOutputEngineInterface::MediaError |
Describes an error during a media playback operation
aace::alexa::MediaPlayerEngineInterface::MediaError
using aace::audio::AudioOutput::FocusAction = aace::audio::AudioOutputEngineInterface::FocusAction |
Describes a focus action platform interface reports or requests
aace::audio::AudioOutputEngineInterface::FocusAction
|
strong |
|
pure virtual |
Notifies the platform implementation to prepare for playback of an AudioStream
audio source. After returning true
, the Engine will call play()
to initiate audio playback.
[in] | stream | The AudioStream object that provides the platform implementation audio data to play. |
[in] | repeating | true if the platform should loop the audio when playing. |
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to prepare for playback of a URL audio source. After returning true
, the Engine will call play()
to initiate audio playback.
[in] | url | The URL audio source to set in the platform media player |
[in] | repeating | true if the platform should loop the audio when playing. |
[in] | playbackContext | The context related to playback of an audio item. |
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation only if prepared media allows platform interface to duck the volume if any high priority audio stream is in the focus. If platform interface ducks the volume, report the state using audioFocusEvent
always. If mayDuck
is not called, platform interface can assume that media is not allowed to duck.
|
pure virtual |
Notifies the platform implementation to start playback of the current audio source. After returning true
, the platform implementation must call mediaStateChanged()
with MediaState.PLAYING
when the media player begins playing the audio or mediaError()
if an error occurs.
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to stop playback of the current audio source. After returning true
, the platform implementation must call mediaStateChanged()
with MediaState.STOPPED
when the media player stops playing the audio or immediately if it is already stopped, or mediaError()
if an error occurs. A subsequent call to play()
will be preceded by calls to prepare()
and setPosition()
.
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to pause playback of the current audio source. After returning true
, the platform implementation must call mediaStateChanged()
with MediaState.STOPPED
when the media player pauses the audio or mediaError()
if an error occurs. A subsequent call to resume()
will not be preceded by calls to prepare()
and setPosition()
.
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to resume playback of the current audio source. After returning true
, the platform implementation must call mediaStateChanged()
with MediaState.PLAYING
when the media player resumes the audio or mediaError()
if an error occurs.
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to move the playback in background. If platform implementation supports audio ducking, reduce the media player volume according to platform guidelines.
true
if the platform implementation successfully attenuated the volume, else false
. If false
is returned, stopDucking
call will not be received.
|
pure virtual |
Notifies the platform implementation to move the playback in foreground. If platform implementation supports audio ducking, restore the media player volume to original value.
true
if the platform implementation successfully restored the volume, else false
. If false
is returned, internal state considers that platform implementation is still in the ducked state which may result into unexpected behavior.
|
pure virtual |
Returns the current playback position of the platform media player. If the audio source is not playing, the most recent position played should be returned.
TIME_UNKNOWN
if the current media position is unknown or invalid.
|
pure virtual |
Notifies the platform implementation to set the playback position of the current audio source in the platform media player.
[in] | position | The playback position in milliseconds to set in the platform media player |
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Returns the duration of the current audio source. If the duration is unknown, then TIME_UNKNOWN
should be returned.
TIME_UNKNOWN
.
|
virtual |
Returns the amount of audio data buffered.
|
pure virtual |
Notifies the platform implementation to set the volume of the output channel. The volume
value should be scaled to fit the needs of the platform.
[in] | volume | The volume to set on the output channel. volume is in the range [0,1]. |
true
if the platform implementation successfully handled the call, else false
|
pure virtual |
Notifies the platform implementation to apply a muted state has changed for the output channel
[in] | state | The muted state to apply to the output channel. MutedState::MUTED when the output channel be muted, MutedState::UNMUTED when unmuted |
true
if the platform implementation successfully handled the call, else false
void aace::audio::AudioOutput::mediaStateChanged | ( | MediaState | state | ) |
Notifies the Engine of an audio playback state change in the platform implementation. Must be called when the platform media player transitions between stopped and playing states.
[in] | state | The new playback state of the platform media player |
void aace::audio::AudioOutput::mediaError | ( | MediaError | error, |
const std::string & | description = "" |
||
) |
Notifies the Engine of an error during audio playback
[in] | error | The error encountered by the platform media player during playback |
[in] | description | A description of the error |
void aace::audio::AudioOutput::audioFocusEvent | ( | FocusAction | action | ) |
Request engine to perform the action mentioned in the parameter.
[in] | action | An FocusAction platform interface wishes to request. |
|
static |
Used when audio time is unknown or indeterminate.
Alexa Auto SDK 4.3 - Copyright 2017-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0