HTTP Dynamic Streaming, Peer-to-Peer Communication, Controls, YouTube

0
118

HTTP Dynamic Streaming

Adobe’s adaptive streaming delivery method, called HTTP Dynamic Streaming, is another option for live or on-demand video playback. This method is similar to Apple’s Adaptive Streaming and Microsoft’s Smooth Streaming.

Because HTTP Dynamic Streaming plays back video files in chunks, additional complex logic needs to be built in to put the segments together in the right order and play them back. Therefore, it is recommended that an Open Source Media Frameworkbased player be used for HTTP Dynamic Streaming.

You can build one from scratch using OSMF, or use a prebuilt solution such as Flash Media Playback or Strobe Media Playback. Video content needs to be prepared for HTTP Dynamic Streaming in a simple post-processing step that creates the segments along with a manifest file that describes the video and its segments. Adobe provides free command-line tools for preparing both on-demand and live streams.

More information on HTTP Dynamic Streaming is available online at http://www.adobe.com/products/httpdynamicstreaming/ and http://www.flashstreamworks.com/archive.php?post_id=1278132166.

 Peer-to-Peer Communication

Real Time Media Flow Protocol (RTMFP) is an Adobe proprietary protocol that enables peer-to-peer communication in Flash Player and the AIR runtime. It opens up possibilities for your applications using video.

Controls

The methods for controlling the stream are play, pause, resume, seek, and close. You cannot stop the stream because it is still downloading. You need to close it completely.

You can check the progress of the stream by checking its time property. Use that value and increment it to seek ahead in the video. You can also seek to a specific time, of course. With progressive download, you can only seek ahead to points in the video file that have been downloaded. With embedded video and RTMP, you can seek anywhere within the video file at any time.

To monitor these events, register for NetStatusEvent and its info.code object:

[code]function onNetEvent(event:NetStatusEvent):void {
switch (event.info.code) {
case “NetStream.Play.Start” :
break;
case “NetStream.Play.Stop”:
break;
case ” NetStream.Pause.Notify” :
break;
case ” NetStream.Unpause.Notify”:
break;
case “NetStream.Buffer.Full”:
break;
case “NetStream.Seek.Notify”:
break;
}
}
}[/code]

You cannot use the Sound object to control the audio part on the video. Use the Sound Transform property instead. Here we are setting the volume to silent:

[code]var transform:SoundTransform = new SoundTransform();
stream.soundTransform = new SoundTransform(0);[/code]

YouTube

It is almost impossible to talk about videos without mentioning YouTube. As you most certainly know, YouTube is a file-sharing video site that has changed the propagation of information via video, whether is it pop culture or current events.

YouTube videos can be played on Android devices if they are encoded with the H.264 video codec.

In both cases, you use a URLRequest:

[code]<uses-permission android:name=”android.permission.INTERNET” />
import flash.net.navigateToURL;
import flash.net.URLRequest;
var youTubePath:String = “http://www.youtube.com/watch?v=”;
var videoID:String = someID;
navigateToURL(new URLRequest(youTubePath + videoID);[/code]

To display the video at full screen, use a different path:

[code]var youTubePath:String = “http://www.youtube.com/watch/v/”;[/code]