Home | Search | Login | RSS
We have 1077 members and counting!
Next Page

1

Previous Page

Thread: Stream switch on the fly

Created on: 02/15/13 04:28 AM

Replies: 2

Cha0s





Joined: 02/15/13

Posts: 2

Stream switch on the fly
02/15/13 4:28 AM

Hello,

First of all, thank you for all the tutorials and this great forum!
It helped me a lot get the basics of FMS!

So, I am building an app that users can publish live streams from FMLE or whatever encoder they use.
The streams will originate mostly from a non-flash encoder (FMLE, Xsplit, Wirecast, etc) so I cannot do anything on the client-side.

I am now trying to make it so that when no stream is published, the server will serve a file from the disk in a loop and when a publisher connects and starts streaming it will switch to the live stream.

Similarly when the publisher stops streaming, I want to switch back to the loop file stream.

The whole concept is, that whether a publisher is streaming or not, the viewers will always 'see' something and most of all they don't get disconnected when the stream stops (as it happens by default when the publisher stops streaming).


I've managed to create a recursive function that will stream a video file from the disk over and over.

But I cannot find anything in the documentation that will allow me to switch streams server-side without waiting for the previous Stream.play() to finish.


Is there a workaround or any ideas how to implement this functionality on FMS?


Thank you!

Link | Top | Bottom

Cha0s





Joined: 02/15/13

Posts: 2

RE: Stream switch on the fly
02/15/13 7:06 AM

I forgot to mention that setting the 3rd argument of Stream.play() to TRUE, does force the stream to start without waiting for the previous one to finish, but that way the player on the client side (JWplayer in my case) disconnects the viewer.

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1592

RE: Stream switch on the fly
02/18/13 12:02 PM

Thank you and you're welcome!

You can use the onPublish function on the server side to trigger things on the client side. The easiest way I can think of to do what you want is to have the client side try to play the live stream when they hook up, if you get back the "doesn't exist" information object on the netstream then you know it isn't there. So, go play the VOD.

If you have a client connect up and it does exist, then it plays. Simple enough.

If it goes live in the case that they are playing the VOD, you can now take advantage of the onPublish function on the server side to then go tell the clients that are connected up to then stop the VOD and play the live stream.

If they are watching the live stream and it stops, then you then listen for the onUnpublish event on the server side and again send out a message to all the clients that it has stopped and to go play the VOD.

That's the high level explanation of what you need to do.

Link | Top | Bottom

Next Page

1

Previous Page

New Post

Please login to post a response.