Search.../

generateVideoStreamingUrl( )

Generates a URL for streaming a specific video file in the Media Manager.

Description

The generateVideoStreamingUrl() function returns a Promise that resolves to a download URL and its asset key.

To stream different assets of the file, use the assetKeys parameter which generates a video streaming URL for each asset. If no asset key is specified, it defaults to src, which generates one video streaming URL in the original file's format and quality.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function generateVideoStreamingUrl(fileId: string, options: GenerateVideoStreamingUrlOptions): Promise<GenerateVideoStreamingUrlResponse>

generateVideoStreamingUrl Parameters

NAME
TYPE
DESCRIPTION
fileId
string

File ID.

options
Optional
GenerateVideoStreamingUrlOptions

Options to use when generating a video file's streaming URL.

Returns

Return Type:

Promise<
GenerateVideoStreamingUrlResponse
>
NAME
TYPE
DESCRIPTION
downloadUrl
DownloadUrl

URL for streaming a specific file in the Media Manager.

Was this helpful?

Generate a video streaming url (dashboard page code)

Copy Code
1import { files } from 'wix-media.v2';
2
3/* Sample ID value: 'd4dde1_6ce66a7e99db49f5964ef9f3ef97eefc'
4 *
5 * Sample options value:
6 * {
7 * format: 'HLS'
8 * }
9 */
10
11async function myGenerateVideoStreamingUrlFunction(fileId, options) {
12 try {
13 const streamingUrl = await files.generateVideoStreamingUrl(fileId, options);
14
15 return streamingUrl;
16 } catch (error) {
17 console.error(error);
18 // Handle the error
19 }
20}
21
22/* Promise resolves to:
23 * {
24 * "downloadUrl": {
25 * "assetKey": "HLS",
26 * "url": "https://repackager.wixmp.com/video.wixstatic.com/video/d4dde1_6ce66a7e99db49f5964ef9f3ef97eefc/,720p,360p,1080p,480p,/mp4/file.mp4.urlset/master.m3u8"
27 * }
28 * }
29 */
Generate a video streaming url (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { files } from 'wix-media.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample ID value: 'd4dde1_6ce66a7e99db49f5964ef9f3ef97eefc'
6 *
7 * Sample options value:
8 * {
9 * format: 'HLS'
10 * }
11 */
12
13export const myGenerateVideoStreamingUrlFunction = webMethod(Permissions.Anyone, async (fileId, options) => {
14 try {
15 const elevatedGenerateVideoStreamingUrl = elevate(files.generateVideoStreamingUrl);
16 const streamingUrl = await elevatedGenerateVideoStreamingUrl(fileId, options);
17
18 return streamingUrl;
19 } catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23});
24
25/* Promise resolves to:
26 * {
27 * "downloadUrl": {
28 * "assetKey": "HLS",
29 * "url": "https://repackager.wixmp.com/video.wixstatic.com/video/d4dde1_6ce66a7e99db49f5964ef9f3ef97eefc/,720p,360p,1080p,480p,/mp4/file.mp4.urlset/master.m3u8"
30 * }
31 * }
32 */
33