Copy link to clipboard
Copied
hi,
i want to stream like a tv channel a list of files.
in this case i have 6 files:
s1.flv - s2.flv - s3.flv - s4.flv - s5.flv - s6.flv
this videos are 1366 * 768 pixeles.
this videos are about 15 seconds every one, they are short videos.every video are about 700 kb
in the server inside the application file i have an app name: test nd inside test i have streams/_definst_
/test
/test/streams
/test/streams/_definst_ (here there are the videos)
my main.asc source is:
application.onAppStart = function(){
this.clientStream = Stream.get("clientPlayStream");
this.clientStream.play("s1", 0, -1);
this.clientStream.play("s2", 0, -1, false);
this.clientStream.play("s3", 0, -1, false);
this.clientStream.play("s4", 0, -1, false);
this.clientStream.play("s5", 0, -1, false);
this.clientStream.play("s6", 0, -1, false);
application.onStatus = function(info){
if(info.code=="NetStream.Play.Stop") {
this.clientStream.play("p1", 0, -1);
this.clientStream.play("p2", 0, -1, false);
this.clientStream.play("p3", 0, -1, false);
this.clientStream.play("p4", 0, -1, false);
this.clientStream.play("p5", 0, -1, false);
this.clientStream.play("p6", 0, -1, false);
}
}
}
what im trying to do is to stream this 6 files and then loop.
and i have a class in my fla file:
package {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.AsyncErrorEvent;
import flash.net.NetStream;
import flash.media.Video;
public class MUAC extends Sprite {
var nc:NetConnection;
var ns:NetStream;
var video:Video;
var videoURL:String="clientPlayStream";
public function MUAC() {
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://localhost/test/");
}
private function netStatusHandler(event:NetStatusEvent):void {
trace("event.info.level: " + event.info.level + "\n", "event.info.code: " + event.info.code);
switch (event.info.code) {
case "NetConnection.Connect.Success" :
// Call doPlaylist() or doVideo() here.
doVideo(nc);
break;
case "NetConnection.Connect.Failed" :
// Handle this case here.
break;
case "NetConnection.Connect.Rejected" :
// Handle this case here.
break;
case "NetStream.Play.Stop" :
// Handle this case here.
break;
case "NetStream.Play.StreamNotFound" :
// Handle this case here.
break;
case "NetStream.Publish.BadName" :
trace("The stream name is already used");
// Handle this case here.
break;
}
}
// play a recorded stream on the server
private function doVideo(nc:NetConnection):void {
ns=new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.client = new CustomClient();
video = new Video();
video.attachNetStream(ns);
ns.play(videoURL);
addChild(video);
video.width = 1366
video.height = 768;
}
}
}
class CustomClient {
public function onMetaData(info:Object):void {
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onPlayStatus(info:Object):void {
trace("handling playstatus here");
}
}
this looks fine, but when i try i run the app, i run the flash file the videos are too slow.
i dont know whats going on. can someone help me to fine whats going on ???
thanks.
Copy link to clipboard
Copied
I think there is typo in your server-side code , probabaly you might have typed it wrong here because there are not p1.flv,p2.flv ..
I really dont know why they should play slow for you. But i can suggest you try with this code and see if things fine - I am just giving more correct code but dont know whether it will solve slow play which you are seeing ( i.e. flash file video is too slow)
Server-side:
application.onAppStart = function(){
this.clientStream = Stream.get("clientPlayStream");
this.clientStream.onStatus = function(info){
if(info.code=="NetStream.Play.Stop") {
this.clientStream.play("s1", 0, -1,false);
this.clientStream.play("s2", 0, -1, false);
this.clientStream.play("s3", 0, -1, false);
this.clientStream.play("s4", 0, -1, false);
this.clientStream.play("s5", 0, -1, false);
this.clientStream.play("s6", 0, -1, false);
}
}
this.clientStream.play("s1", 0, -1);
this.clientStream.play("s2", 0, -1, false);
this.clientStream.play("s3", 0, -1, false);
this.clientStream.play("s4", 0, -1, false);
this.clientStream.play("s5", 0, -1, false);
this.clientStream.play("s6", 0, -1, false);
}
Client-end:
....
....
ns.setBufferTime(2);
ns.play(videoURL,"live");
See if this works fine for you.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now