Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

How do I dynamically load a new video - JW 7


I want to maintain the current state of the player and load a new file source. I do not see anything in the JavaScript API.

I also see methods available on the player object that are not documented in the API, like attachMedia. Are these documented anywhere else?

Thank you

11 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

Based on the documentation here:
https://support.jwplayer.com/customer/en/portal/articles/1413089-javascript-api-reference#playlist

jwplayer().load(“video.mp4”);

Should work as expected.

As far as the other available methods you see, they are methods we use internally and they are not documented.

bmartin N/A

User  
0 rated :

Thank you for your reply. When I attempt to use an RTMP stream as my file to load I get the following response:

XMLHttpRequest cannot load rtmp://server.example.com/samplevideo-7. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

For troubleshooting, I initialize the player with the following code:

playerInstance = $window.jwplayer(divId);

Later, on a button click, I run:

playerInstance.load(playbackUrl);

George

JW Player Support Agent  
0 rated :

It seems as if this document should help:
https://support.jwplayer.com/customer/portal/articles/1403679-crossdomain-file-loading

If you can send over a stream and a test page I could have a closer look

bmartin N/A

User  
0 rated :

The initial stream is an RTMP stream that has no issues loading. I assume the load() function is attempting to pull in the stream in a different manner than setup() function.

Unfortunately due to the nature of the application I cannot quickly set up an example. If necessary I can set something up on a gist if necessary.

George

JW Player Support Agent  
0 rated :

I would also setup the player with regular javascript instead of jQuery

bmartin N/A

User  
0 rated :

It is setup with the angular implementation of $window.

George

JW Player Support Agent  
0 rated :

Have you tried jwplayer(“id”) instread of $window.jwplayer(“id”)?

bmartin

User  
0 rated :

Yes but due to our coding guidelines we adhere to attaching to the $window element. Either way it does not appear that I can dynamically load a new RTMP stream.

George

JW Player Support Agent  
0 rated :

You can load a new stream, but it will change the player state.

You can either call jwplayer().load() or jwplayer().setup()

bmartin

User  
0 rated :

Ok, thank you. Are there any plans for a feature to swap out the file being played without changing state?

George

JW Player Support Agent  
0 rated :

Not that I am aware of

This question has received the maximum number of answers.