Wejn s.r.o.

Solving complicated IT problems is our hobby.

How to Pass Query String in RTMP Connect Url in JWPlayer6

Not long ago one of our customers migrated from JWPlayer5 to the brand new JWPlayer6.

To their astonishment, the separate streamer and stream parameters were replaced by a single file parameter.

That works quite well until it doesn’t.

If you happen to need query string in your NetConnection.connect() then you might not be able to properly pass it within the single file param.

That might happen when you’re using token based authentication.

Checking with LongtailVideo’s support, their suggestion was to use the syntax:

rtmp://host/app/?query=string&here=now/streamname

which would inevitably break if either streamname or any part of the query string contained any slashes. Not to mention this way of composing URL parts together is, in our view, a very poor practice.

Fortunately the JWPlayer6’s RTMPMediaProvider class source code reveals undocumented code that makes it possible to work around this file feature.

When you, in your embed code, force the type to be rtmp and set streamer parameter to your connect URL then the file parameter is interpreted to be just a stream name.

In essence, using following embed code:

1
2
3
4
5
6
7
8
9
10
jwplayer("myElement").setup({
  primary: 'flash',
  type: 'rtmp',
  streamer: 'rtmp://example.com/vod/?query=string&here=now',
  file: "mp4:folder/myVideo",
  image: "/assets/myVideo.jpg",
  width: 640,
  height: 360,
  autostart: true
});

will allow you to call the desired connect URL and then play a stream (file) located within some sub-folder.

As explained, this feature is not documented but works great so far.

Last time we checked this workaround works as intended: 2013-03-07, in JWPlayer 6.2.