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

Help changing video source in java script


I am working to convert our code to support the JW Player 6 (from v5). I am having trouble getting the java script to change video source. The function is triggered when the user clicks a button on the browser.

I'm pretty sure it's in this line:

bc.. .
var toplay= "file: 'http://<%=node%>.<%=dc %>.OurWowzaServer.net:1935/<%=PubPoint %>' + '/smil:' + Channel + '.smil/playlist.m3u8'";



but not sure exactly how to fix. Can anyone advise please? thank you



bc.. <script type="text/javascript">
jwplayer('mediaplayer').setup({
'id': 'playerID',
'width': '720',
'height': '410',
'controlbar': 'over',
'autostart': 'true',
'live': 'true',
'file': 'http://<%=node%>.<%=dc %>.OurWowzaServer.net:1935/<%=PubPoint %>/smil:<%=Feed %>.smil/playlist.m3u8'


});
function ChangeVideo(Channel) {

var element = document.getElementById('mediaplayer');
var toplay= "file: 'http://<%=node%>.<%=dc %>.OurWowzaServer.net:1935/<%=PubPoint %>' + '/smil:' + Channel + '.smil/playlist.m3u8'";
jwplayer(element).load(toplay);
jwplayer(element).play();
}
</script>


19 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Can I see where this is running?

JW Player

User  
0 rated :

http://www.cnsmedia.net/sundiegolive/jwp6.asp

it's the buttons that change the video source that fire off the function.

thank you

JW Player

User  
0 rated :

ps: I have an audio player below the buttons that I have not gotten to yet. it's trying to play an audio stream. no idea yet but also have not dug into that. it's this change video source that has me stumped right now.

thanks again

Ethan Feldman

JW Player Support Agent  
0 rated :

It looks like when I click a link, this file comes up, but it times out – http://wowza.nyc.commercialnetworkservices.net:1935/sundiegolive/smil:harborisland-e.smil/jwplayer.rss

JW Player

User  
0 rated :

that's suppose to be the new source file. it's a wowza server (live stream)

it's working in v5 player, check out www.sundiegolive.com

Do you know how I can get this working with v6?

thank you

Ethan Feldman

JW Player Support Agent  
0 rated :

Firefox can’t establish a connection to the server at wowza.nyc.commercialnetworkservices.net:1935.

That to me means the location is incorrect…

JW Player

User  
0 rated :

this part right here is the issue. what is wrong with it? It's the code that changes the source.

bc.. });
function ChangeVideo(Channel) {
var element = document.getElementById('mediaplayer');
var toplay= "file: 'http://<%=node%>.<%=dc %>.OurWowzaServer.net:1935/<%=PubPoint %>' + '/smil:' + Channel + '.smil/playlist.m3u8'";
jwplayer(element).load(toplay);
jwplayer(element).play();
}




I've tried playlist.m3u8, jwplayer.rss, playlist.rss. nothing works. error is "Playlist could not be loaded. Playlist is not a valid RSS feed.". We are using a wowza server.

thank you

Ethan Feldman

JW Player Support Agent  
0 rated :

What I mean is, the url does not exist. Try to go to it in your browser.

JW Player

User  
0 rated :

Yes, thank you - the stream name is cAse sensitive and the function had all lower case, but unfortunately it's still not working after being corrected.

so back to square one:

bc.. function ChangeVideo(Channel) {


var element = document.getElementById('mediaplayer');
var toplay = 'http://wowza.OurWowzaServer.net:1935/SunDiegoLive' + '/smil:' + Channel + '.smil/playlist.rss';

jwplayer(element).src = toplay;
jwplayer(element).load(toplay);
jwplayer(element).play();

}



works in JW5, not 6. why not?

thank you

JW Player

User  
0 rated :

Do you have to use javascript to specify file for windows phone8? I have a m38u file (for ipads/ipods/iphones) and f4m for others - currently it seems to be working on all but windows phone 8 -

Ethan Feldman

JW Player Support Agent  
0 rated :

Can I just have a full path to a working file that I can quickly test?

JW Player

User  
0 rated :

the path is dynamic, depends which button they click.

so for harbor island-e, it would be

(I'm putting this in a code block to prevent a browser link)

bc.. http://wowza.nyc.commercialnetworkservices.net:1935/SunDiegoLive/smil:harborisland-e.smil/jwplayer.rss



etc.

the page will use a m38u file for the initial video source if it detects a phone or ipad, etc.. but the function to change the source has always been jwplayer.rss, and it's worked up till v6. now mobile still seems to work but not on the desktops. I've tried jwplayer.rss, playlist.rss, playlist.m3u8, every combo I can think of. error is "playlist is not a valid rss feed". However as you can see the same URL will play the video on first load just fine. odd huh

so my question is: how can I get the code working to change the live source?

thank you

Ethan Feldman

JW Player Support Agent  
0 rated :

The does not work in JW6 – http://wowza.nyc.commercialnetworkservices.net:1935/SunDiegoLive/smil:harborisland-e.smil/jwplayer.rss

Because you have:

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/">
	<channel>
		<item>
			<title>harborisland-e.smil</title>
			<description>harborisland-e.smil</description>
			<jwplayer:streamer>rtmp://wowza.nyc.commercialnetworkservices.net:1935/SunDiegoLive/_definst_</jwplayer:streamer>
			<media:group>
				<media:content url="mp4:harborisland-e.stream_720p" bitrate="1800"/>
				<media:content url="mp4:harborisland-e.stream_360p" bitrate="850"/>
				<media:content url="mp4:harborisland-e.stream_240p" bitrate="350"/>
				<media:content url="mp4:harborisland-e.stream_160p" bitrate="200"/>
			</media:group>
		</item>
	</channel>
</rss>



In JW5, there was file / streamer / provider.

In JW6, RTMP streams are just done as one long path - http://www.longtailvideo.com/support/jw-player/28854/using-rtmp-streaming

JW Player

User  
0 rated :

one long path pointing to a smil file, right? (It's a MBR stream.)

I edited the code to change the player source in the function to the following:

bc.. http://wowza.nyc.commercialnetworkservices.net:1935/SunDiegoLive/smil:harborisland-e.smil



and it errors out that the playlist is not a valid rss feed. so I'm going in circles....

how would you change the source video in java script code for a live stream?

thank you

Ethan Feldman

JW Player Support Agent  
0 rated :

I mean for the RTMP stream itself. Your playlist is using file / streamer, which is for JW5.

JW Player

User  
0 rated :

the playlist is generated by wowza server v4. Is JWP6 not compatible with wowza4?

Ethan Feldman

JW Player Support Agent  
0 rated :

It should be fine, but you are using file / streamer, that syntax does not exist for JW6…

JW Player

User  
0 rated :

that playlist, and the contents in it, are generated by wowza4. so it seems your new JWP6 is not compatible with wowza4 playlists.

Ethan Feldman

JW Player Support Agent  
0 rated :

Then they are generating it based on JW5 and below, and not JW6. Streamer does not work for JW6. It has to be one long file variable.

This question has received the maximum number of answers.