@instructure/studio-player
v1.5.4
Published
Next generation media player for Instructure
Downloads
13,608
Maintainers
Keywords
Readme
studio-player
Sources
sourcesrenamed tosrc: can be an url or an array of objects with the following props:srctypewidthheight
- instead of
labelyou have to provide thewidthandheight, this is important, because the player will be able to collect the qualities based on these.
example:
[
{
src: 'my-video1.mp4',
type: 'video/mp4',
width: 1920,
height: 1080,
},
{
src: 'my-video2.mp4',
type: 'video/mp4',
width: 1280,
height: 720,
},
];Captions
trackshas been renamed tocaptionsidandkindis not usedtypeshould be the subtitle format,vttorsrt
example:
[
{
src: 'my-captions-en.srt',
label: 'English',
language: 'en',
type: 'srt',
},
{
src: 'my-captions-es.srt',
label: 'Spanish',
language: 'es',
type: 'srt',
},
];Kebab menu elements
The kebabMenuElements prop can be used to display a kebab menu in the top right corner of the player.
There are 4 predefined icons currently: media, transcript, share, delete.
[
{
id: 'media',
text: 'Download Media',
icon: 'media',
onClick: id => console.log('Clicked', id),
},
{
id: 'transcript',
text: 'Download Transcript',
icon: 'transcript',
onClick: id => console.log('Clicked', id),
},
];Manage captions menu
If you provide a function as the onCaptionsDelete prop, the Manage Captions menu will appear in the captions menu, and for each caption there will be a menu option to delete that caption.
function deleteCaption(caption: CaptionMetaData) {
// implement your caption deletion logic, alerts, etc.
}
...
<StudioPlayer
...
onCaptionsDelete={deleteCaption}
...
/>Deprecated props compared to old Media Player
these props are no longer used and you can remove them from the code:
onLoadedMetadatacaptionPositionautoShowCaption
Translations
Handling translations is manual for now since we don't except too frequent changes to it.
Upload
One would need to do the proper assume commands to get the rights to access our S3 bucket. Please ask this from an engineer in team.
After one having correct credentials,
./i18n-utils/upload.shUpon proper upload one must see Upload completed successfully! message.
Notice: It might appear that after script runs your source translation file is changed, it sorts keys in alphabetical order. In that case, please commit that change!
Download
One would need to do the proper assume commands to get the rights to access our S3 bucket. Please ask this from an engineer in team.
After one having correct credentials,
./i18n-utils/download.shThis will download the translated content and put it in the correct folder. Feel free to upload to a branch and make a PR from it.
E2E Testing
Setup
- Create a
.envfile:SB_BASE_URL="http://localhost" SB_PORT="6010"
- Create a
Running Tests
pnpm test:pw- Runs Playwright tests in Firefox (Storybook starts automatically)pnpm test:pw:show-report- View the latest test report
Debugging
- One can debug through VS Code extension and tick Show browser option OR
pnpm test:pw <FileName> --debugwhich gives a line-by-line debugger
Notes:
- Using a separate port (e.g.
6010instead of6006) prevents conflicts with your development Storybook instance. - Highly recommended to install Playwright VS Code extension, also check out Getting started in VS Code
YouTube Education Player
In order to use the YouTube Education Player, you need to provide an encrypted payload as STORYBOOK_YOUTUBE_ENCRYPTED_PAYLOAD in .env file.
Generating the Encrypted Payload
- In tweed
docker.compose.override.yml, add theYOUTUBE_EDUCATION_API_KEYto "YouTube Education (Local)" key from 1password factory reset vault in api namespace. - Enable
youtube_pf_edufeature flag in tweed if you haven't done yet. - After restarting the containers, you can generate the encrypted payload by running the following command in api rails console:
Account::Account.first.activate! metadata = TweedMediaManagement::ExternalMetadata.from_url("<YOUTUBE_VIDEO_URL>") media = TweedMediaManagement::Media.create!(user: User::User.first, external_metadata: metadata, title: "some title") YoutubeEducationEncryptor.encrypt_embed_config(media) - Copy the generated encrypted payload and set it as
STORYBOOK_YOUTUBE_ENCRYPTED_PAYLOADin your.envfile.
Playback directly from Notorious
- First you need to obtain the media id. You can either directly get it from Notorious SiteAdmin or use the Expose Media ID extension in the browser.
- Once you have the media id, you can generate a playback url by running the following command in notorious web rails console:
media = Media.find_by_public_guid("<MEDIA_ID>") media.original.transcodings.first.drm_playback_url - Use the generated playback url as the
src.
