Media Handler

class afc.media.media_handler.AudioHandler(media_source=MediaSource.STATIC, path=None, spec=None)
class MediaFormat(value)

An enumeration.

class afc.media.media_handler.ImageHandler(media_source=MediaSource.STATIC, path=None, spec=None, image_shape=ImageShape.SQUARE)
class ImageShape(value)

An enumeration.

class MediaFormat(value)

An enumeration.

class afc.media.media_handler.MediaHandler(media_source=MediaSource.STATIC, path=None, spec=None)

Base class for media handlers for various types of media.

Each instance of a MediaHandler is responsible for a single media asset. A block or game may utilize multiple MediaHandlers to manage its diverse media requirements.

The method “get_media” is used to retrieve a media asset. The MediaHandler first checks if the asset already exists in the world-wide resource handler (or its cache) or in its own story index. If the asset exists, it is returned along with its location.

If the asset does not exist, the MediaHandler checks if it has a “specification” for creating the media. If such a specification exists, the MediaHandler generates the media based on the story namespace and source type, registers it in the appropriate location, and returns the newly created media and its location.

There are three ‘sources’ for specified media: 1. Static: These are world-wide resources that may require initial generation from a specification if they do not already exist. 2. Procedural: These are world-wide resources that can be generated from a specification along with additional parameters. For example, an image of a location may have two versions, one for day and one for night. The MediaHandler uses the “time of day” parameter to select or generate the correct image. 3. Dynamic: These are story-wide procedural resources that are customized based on kwargs drawn from the current story namespace.

Static and procedural assets are registered/cached with the world-wide resource handler, while dynamic assets are registered/cached with the current story index.

class afc.media.media_handler.MediaSource(value)

An enumeration.

class afc.media.media_handler.MediaSpecification
class afc.media.media_handler.MediaType(value)

An enumeration.