Reputation: 1753
A Video player is created using "Video" in flash action script 3.0. And played video using net stream. The sample code is:
connection = new NetConnection();
connection.connect(null);
on connection success stream and video crested and played.
stream = new NetStream(connection);
video = new Video();
video.width = stage.stageWidth;
video.height = stage.stageHeight;
video.attachNetStream(stream);
stream.play(videoURL);
Video is playing correctly. I want to display subtitle for the video. I have .srt formeted file for the video, any solution in as3 to load the SRT for the Video on flash.
Upvotes: 0
Views: 418
Reputation: 1624
Writing a .srt parser isn't that difficult. Use the CuePoint
API provided by AS3 to add cuepoints to your Video
instance at runtime. Then listen for the onCuePoint
event and display the relevant text in a text field.
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var client = {};
client.onCuePoint = function(info:Object):void
{
var key:String;
for (key in info)
{
trace(key + ": " + info[key]);
}
};
ns.client = client;
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
ns.play("video.flv");
Instead of tracing the output, you can display text in an on-screen text field.
Upvotes: 1