Module: Toybox::Media

Overview

The Media module provides objects and methods for implementing audio content provider apps.

This includes interfaces and methods for managing downloaded media content as well as interfaces used to provide required information to the system for playback.

Since:

  • 3.0.0

App Types:

  • App

  • Audio Content Provider App

  • Glance Support

  • Background Services

Defined Under Namespace

Classes: ActiveContent, AlbumArt, AudioFormat, CacheStatistics, Content, ContentDelegate, ContentIterator, ContentMetadata, ContentRef, ContentRefIterator, CustomButton, PlaybackProfile, PlayerColors, ProviderIconInfo, SyncDelegate, SystemButton

Constant Summary

PLAYBACK_POSITION_START = 0

The playback position when the song has begun to play

Since:

  • 3.0.0

CONTENT_TYPE_INVALID = 0

Invalid content type

Since:

  • 3.0.0

CONTENT_TYPE_AUDIO = 1

Content type for Audio

Since:

  • 3.0.0

ENCODING_INVALID = 0

Invalid encoding type

Since:

  • 3.0.0

ENCODING_ADTS = 1

ADTS audio encoding type

Since:

  • 3.0.0

ENCODING_MP3 = 2

MP3 audio encoding type

Since:

  • 3.0.0

ENCODING_M4A = 3

M4A audio encoding type

Since:

  • 3.0.0

ENCODING_WAV = 4

WAV audio encoding type

Since:

  • 3.0.0

IMAGE_FORMAT_INVALID = 0

Invalid media content image format

Since:

  • 3.0.0

IMAGE_FORMAT_JPEG = 1

JPEG media content image format

Since:

  • 3.0.0

IMAGE_FORMAT_PNG = 2

PNG media content image format

Since:

  • 3.0.0

PLAYBACK_CONTROL_SHUFFLE = 0

The “shuffle” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_PREVIOUS = 1

The “previous track” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_NEXT = 2

The “next track” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_SKIP_FORWARD = 3

The “skip forward x seconds” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_SKIP_BACKWARD = 4

The “skip backward x seconds” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_REPEAT = 5

The “repeat” operation is allowed

Since:

  • 3.0.0

PLAYBACK_CONTROL_RATING = 6

The track “rating” operation is allowed

Since:

  • 3.0.3

PLAYBACK_CONTROL_PLAYBACK = 7

The “play/pause” operation is allowed

Since:

  • 3.0.3

PLAYBACK_CONTROL_VOLUME = 8

The “volume” button - if not provided it will be added to the end of the playback controls

Since:

  • 3.0.3

PLAYBACK_CONTROL_SOURCE = 9

The “source” button - if not provided it will be added to the end of the playback controls

Since:

  • 3.0.3

PLAYBACK_CONTROL_LIBRARY = 10

The “library” button - If provided it will be used for the library button UI.

Since:

  • 3.0.3

SONG_EVENT_START = 0

Indicates that a song was started from the beginning.

See Also:

Since:

  • 3.0.0

SONG_EVENT_SKIP_NEXT = 1

Indicates that a song was skipped and the next song was requested.

See Also:

Since:

  • 3.0.0

SONG_EVENT_SKIP_PREVIOUS = 2

Indicates that a song was skipped and the previous song was requested.

See Also:

Since:

  • 3.0.0

SONG_EVENT_PLAYBACK_NOTIFY = 3

Indicates that a song was played for the duration set in PlaybackProfile.playbackNotificationThreshold.

See Also:

Since:

  • 3.0.0

SONG_EVENT_COMPLETE = 4

Indicates that a song was completed.

See Also:

Since:

  • 3.0.0

SONG_EVENT_STOP = 5

Indicates that a song was stopped in the middle of playback.

See Also:

Since:

  • 3.0.0

SONG_EVENT_PAUSE = 6

Indicates that a song was paused in the middle of playback.

See Also:

Since:

  • 3.0.0

SONG_EVENT_RESUME = 7

Indicates that a song was resumed after being paused.

See Also:

Since:

  • 3.0.0

REPEAT_MODE_OFF = 0

Repeat is off

Since:

  • 3.0.0

REPEAT_MODE_ONE = 1

Repeat the current track

Since:

  • 3.0.0

REPEAT_MODE_ALL = 2

Repeat all tracks

Since:

  • 3.0.0

BUTTON_STATE_DEFAULT = 0

The default state for a button. This is a valid state for all buttons.

Since:

  • 3.0.3

BUTTON_STATE_DISABLED = 1

The button is shown but not selectable. This is a valid state for all buttons.

Since:

  • 3.0.3

BUTTON_STATE_ON = 2

The button is considered “on”. This is a valid state for the PLAYBACK_CONTROL_PLAYBACK, PLAYBACK_CONTROL_SHUFFLE, and PLAYBACK_CONTROL_REPEAT buttons.

Since:

  • 3.0.3

BUTTON_STATE_OFF = 3

The button is considered “off”. This is a valid state for the PLAYBACK_CONTROL_PLAYBACK, PLAYBACK_CONTROL_SHUFFLE, and PLAYBACK_CONTROL_REPEAT buttons.

Since:

  • 3.0.3

BUTTON_STATE_ALL = 4

The button is considered in the “on” and “all” states. This is a valid state the for the PLAYBACK_CONTROL_SHUFFLE (shuffle all) and PLAYBACK_CONTROL_REPEAT (repeat all) buttons.

Since:

  • 3.0.3

BUTTON_STATE_POSITIVE = 5

The button is considered in the “positive” state. This is a valid state the for the PLAYBACK_CONTROL_RATING button.

Since:

  • 3.0.3

BUTTON_STATE_NEGATIVE = 6

The button is considered in the “negative” state. This is a valid state the for the PLAYBACK_CONTROL_RATING button.

Since:

  • 3.0.3

BUTTON_STATE_NEUTRAL = 7

The button is considered in the “neutral” state. This is a valid state the for the PLAYBACK_CONTROL_RATING button.

Since:

  • 3.0.3

BUTTON_IMAGE_ICON = 0

The normal sized button image

Since:

  • 3.0.3

BUTTON_IMAGE_DETAIL = 1

The larger image for when the icon is highlighted

Since:

  • 3.0.3

Instance Method Summary collapse

Instance Method Details

deleteCachedItem(contentRef) ⇒ Object

Delete an individual cached media item.

Parameters:

Since:

  • 3.0.0


8341
8342
# File 'Monkeybrains.rb', line 8341

def deleteCachedItem(contentRef)
end

getCachedContentObj(contentRef) ⇒ Toybox::Media::Content

Get a Content object by ID from what has been persisted on the system.

Parameters:

Returns:

Since:

  • 3.0.0


8350
8351
# File 'Monkeybrains.rb', line 8350

def getCachedContentObj(contentRef)
end

getCacheStatisticsToybox::Media::CacheStatistics

Get the current size statistics of the media cache.

Returns:

Since:

  • 3.0.0


8356
8357
# File 'Monkeybrains.rb', line 8356

def getCacheStatistics()
end

getContentRefIter(options) ⇒ Toybox::Media::ContentRefIterator

Get a ContentRefIterator object.

The ContentRefIterator is used to iterate over all cached media on the system for the calling app.

Parameters:

Options Hash (options):

Returns:

Since:

  • 3.0.0


8329
8330
# File 'Monkeybrains.rb', line 8329

def getContentRefIter(options)
end

notifySyncComplete(errorMessage) ⇒ Object

Deprecated.

This method will be removed in Connect IQ 6.0.0

Send a system notification to indicate that the sync completed.

Parameters:

  • errorMessage (Toybox::Lang::String)

    A descriptive error message if a failure occurred. If the sync completes successfully, null should be passed to this method.

See Also:

Since:

  • 3.0.0


8872
8873
# File 'Monkeybrains.rb', line 8872

def notifySyncComplete(errorMessage)
end

notifySyncProgress(percentageComplete) ⇒ Object

Deprecated.

This method will be removed in Connect IQ 6.0.0

Send a system notification to indicate overall sync progress.

Parameters:

  • percentageComplete (Toybox::Lang::Number)

    An integer from 0 to 100 indicating the completion percentage.

See Also:

Since:

  • 3.0.0


8862
8863
# File 'Monkeybrains.rb', line 8862

def notifySyncProgress(percentageComplete)
end

requestPlaybackProfileUpdateObject

Since:

  • 3.0.0


8899
8900
# File 'Monkeybrains.rb', line 8899

def requestPlaybackProfileUpdate()
end

resetContentCacheObject

Delete the cached media content and reset the encryption key for the app.

Since:

  • 3.0.0


8334
8335
# File 'Monkeybrains.rb', line 8334

def resetContentCache()
end

setAlbumArt(albumArt) ⇒ Object

Set the album art for the currently playing song

Parameters:

  • albumArt (BitmapResource)

    The album art to display. If null then the system's default album art will be displayed.

Since:

  • 3.0.10


8889
8890
# File 'Monkeybrains.rb', line 8889

def setAlbumArt(albumArt)
end

startPlayback(args) ⇒ Object

Exit the AudioContentProviderApp in its current mode and launch it in playback mode.

Parameters:

Raises:

Since:

  • 3.0.0


8883
8884
# File 'Monkeybrains.rb', line 8883

def startPlayback(args)
end

startSyncObject

Deprecated.

This method will be removed in Connect IQ 6.0.0

Exit the AudioContentProviderApp in its current mode and launch it in sync mode.

See Also:

Since:

  • 3.0.0


8897
8898
# File 'Monkeybrains.rb', line 8897

def startSync()
end