Building a Live Video Switcher with Flash Communication Server MX
Understanding the Switch Concept
Before you start building the video switching application, let's first take a look at how the switch will happen and how you can deliver the best possible experience to your users.
There are two ways to make a video switch with Flash Communication Server:
- Use messaging to call functions remotely on each connected instance of Flash Player to start playing a different stream. This is similar to pushing a link to a user informing Flash Player to "change the channel." Messaging for this solution can occur using either NetConnection or SharedObject.
- Use server-side ActionScript to change the source of a stream that each Flash Player instance is subscribed to. This is similar to doing a simple "cut" between different cameras (think of a TV studio).
There are three key problems with the messaging option:
- Synchronization: When you call a video switch, each player is instantly triggered to switch the video. The problem is that the video will appear to cut in the wrong spot. Each player maintains its own buffer (approximately two seconds) and so the switch may appear to occur too early.
- Rebuffering: Each time Flash Player subscribes to (plays) another stream, it must rebuffer the stream. This causes an undesirable pause in the stream.
- Performance: Significant load will be placed on Flash Communication Server when all Flash Player clients are instructed to play a new stream simultaneously.
This article focuses on using server-side ActionScript to produce the best possible experience for receiving live video with absolute synchronization, no rebuffering, and optimal Flash Communication Server performance.
All Flash Player clients will subscribe to a single "program" stream. Server-side ActionScript will perform the switch on the server. Sustaining the playback stream on the Flash Player means it will not need to rebuffer and everyone will see the switch at the proper time in the video. This solution also produces less CPU load on the server.
There are three applications that make up this solution:
- Broadcaster client
- Viewer client
- Switcher client
I explain each part of the application separately so you can understand how each interface operates and how server-side ActionScript interacts with each client. Let's start with the Broadcaster application.