Load stream player dynamically

#1

Is there a way to initialize a stream after page load. If by example i create the stream tag by javascript dynamically?

eg. using jquery :

('<stream id="streamId" src="5d5bc37ffcf54c9b82e996823bffbb81"</stream>').appenTo('body'); (‘streamId’).initStream(); <-- does something like this exists ?

Do you recommend any other method?

#2

Was also looking for something like this but couldn’t find it. Decided to use the Dash.js player instead, as it supports this (and more).

#3

Thanks @elecdes, but how did you get the videos URL ?

#4

The format of the URL to pass to Dash.js (eg MediaPlayer::initialize or ::attachSource) is as follows:
https://videodelivery.net/VIDEO_ID/manifest/video.mpd
Where VIDEO_ID is the cloudflare stream id (eg 5d5bc37ffcf54c9b82e996823bffbb81, which you can get from the ‘Get link’/‘Get embed code’ buttons on the Stream dashboard, or from the Stream API), or the signed token.

#5

This is great @elecdes. Thanks a lot.

#6

After creating new stream tag call window.__stream.init();