Show:

Expand-assets Class

These docs have moved here.
Collection: mixins

Reference for DEVELOPERS of new frames only! Mixin to allow users to provide audio/video and image source values as either relative paths within a base directory or as full paths. If using along with other mixins, this should be listed LAST to enable those mixins to add to the set of assets that need to be expanded if needed. When adding this mixin to a frame, you will need to define a property of the frame assetsToExpand, which indicates which parameters might be source objects that need expansion. assetsToExpand should be an object with keys image, video, and audio, and each value should be an Array of parameter names that provide sources for resources of the corresponding type. E.g.,

   {
       'image': ['leftObjectPic', 'rightObjectPic'],
       'audio': ['introAudio', 'testAudio'],
       'video': ['objectDemoVideo']
   }

This is defined directly within your frame, e.g.:

    export default ExpFrameBaseComponent.extend(ExpandAssets, {
        ...
        type: 'exp-my-cool-frame',
        assetsToExpand:     {
            'image': ['leftObjectPic', 'rightObjectPic'],
            'audio': ['introAudio', 'testAudio'],
            'video': ['objectDemoVideo']
            },
        ...,
        meta: {...},
        actions: {...}
    });

The user of your frame can then optionally provide baseDir, audioTypes, and videoTypes parameters to indicate how to expand relative paths. How expansion works:

  • Images: Suppose the list assetsToExpand['image'] contains centerStimulus. If centerStimulus is provided as a full URL (with :// in it), nothing will happen to it. But if centerStimulus is a string that is not a full URL, it will be transformed during the didReceiveAttrs hook to baseDir + 'img/' + centerStimulus.
  • Audio: Suppose the list assetsToExpand['audio'] contains utterance1. If utterance1 is a nonempty string (rather than an object/Array), e.g., goodmorning, and audioTypes has been set to ['typeA', 'typeB'], then utterance1 will be expanded out to
        [
            {
                src: 'baseDir' + 'typeA/goodmorning.typeA',
                type: 'audio/typeA'
            },
            {
                src: 'baseDir' + 'typeB/goodmorning.typeB',
                type: 'audio/typeB'
            }
        ]
  • Video: Same as audio, but using the types from videoTypes. Important: During the didReceiveAttrs hook, your frame will acquire new properties [parameterName]_parsed for each of the parameters named in assetsToExpand. These properties will hold the expanded values. E.g., in the example above, you would now have a centerStimulus_parsed property. This is what you should use for showing/playing images/audio/video in your frame template. Advanced use: the property names in assetsToExpand can be either full parameter names as in the examples above, or can be of the form parameterName/subProperty. If using the parameterName/subProperty syntax, instead of processing the parameter parameterName, we will expect that that parameter is either an object with property subProperty (which will be expanded) or an Array of objects with property subProperty (which will be expanded). The original value of the parameterName parameter may in this case be mutated as assets are expanded. However, your frame will still also acquire a new property [parameterName]_parsed which you should use for accessing the processed values. This avoids potential problems with the template being rendered using the original values and not updated.

Properties

assetsToExpand

String private

Specific to this element. Defined in app/mixins/expand-assets.js:98

Object describing which properties may need expansion

audioTypes

String[]

Specific to this element. Defined in app/mixins/expand-assets.js:126

List of audio types to expect for any audio specified just with a string rather than with a list of src/type objects. If audioTypes is ['typeA', 'typeB'] and an audio source is given as intro, the audio source will be expanded out to

[
    {
        src: 'baseDir' + 'typeA/intro.typeA',
        type: 'audio/typeA'
    },
    {
        src: 'baseDir' + 'typeB/intro.typeB',
        type: 'audio/typeB'
    }
]

Default: ['mp3', 'ogg']

baseDir

String

Specific to this element. Defined in app/mixins/expand-assets.js:106

Base directory for where to find stimuli. Any image src values that are not full paths will be expanded by prefixing with baseDir + img/. Any audio/video src values provided as strings rather than objects with src and type will be expanded out to baseDir/avtype/[stub].avtype, where the potential avtypes are given by audioTypes and videoTypes.

baseDir should include a trailing slash (e.g., http://stimuli.org/myexperiment/); if a value is provided that does not end in a slash, one will be added.

Default: ''

videoTypes

String[]

Specific to this element. Defined in app/mixins/expand-assets.js:154

List of video types to expect for any audio specified just with a string rather than with a list of src/type objects. If videoTypes is ['typeA', 'typeB'] and a video source is given as intro, the video source will be expanded out to

[
    {
        src: 'baseDir' + 'typeA/intro.typeA',
        type: 'video/typeA'
    },
    {
        src: 'baseDir' + 'typeB/intro.typeB',
        type: 'video/typeB'
    }
]

Default: ['mp4', 'webm']