File size: 1,666 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {
	VIDEO_EDITOR_SET_POSTER_URL,
	VIDEO_EDITOR_SHOW_ERROR,
	VIDEO_EDITOR_SHOW_UPLOAD_PROGRESS,
	VIDEO_EDITOR_UPDATE_POSTER,
} from 'calypso/state/action-types';

import 'calypso/state/data-layer/wpcom/videos/poster';
import 'calypso/state/editor/init';

/**
 * Returns an action object to indicate that a request has been made to update the video poster.
 * @param {string} videoId  ID of the video
 * @param {Object} params  Poster data
 * @param {number} [params.atTime]  Number of seconds into the video at which to get the poster
 * @param {Object} [params.file]  An image to attach to the video
 * @param {Object} meta Relevant meta data like site id and media id
 * @param {string} [meta.mediaId] Media identifier
 * @returns {Object} Action object
 */
export const updatePoster = ( videoId, params, meta ) => ( {
	type: VIDEO_EDITOR_UPDATE_POSTER,
	videoId,
	params,
	meta,
} );

/**
 * Returns an action object to indicate that the poster for the video has been updated successfully.
 * @param  {string} posterUrl Poster URL
 * @returns {Object} Action object
 */
export const setPosterUrl = ( posterUrl ) => ( { type: VIDEO_EDITOR_SET_POSTER_URL, posterUrl } );

/**
 * Returns an action object to indicate that the poster for the video failed to update.
 * @returns {Object} Action object
 */
export const showError = () => ( { type: VIDEO_EDITOR_SHOW_ERROR } );

/**
 * Returns an action object to indicate the poster upload progress.
 * @param  {string} percentage  Upload progress percentage
 * @returns {Object} Action object
 */
export const showUploadProgress = ( percentage ) => ( {
	type: VIDEO_EDITOR_SHOW_UPLOAD_PROGRESS,
	percentage,
} );