Copy link to clipboard
Copied
While streaming the DVR i get the following error "ReferenceError: Error #1069: Property onTimeCoordInfo not found on dvrlive and there is no default value." here i have attached the code i did am i want to do anything more? i didnt use any server side code. Any help appreciated thanks in advance.
DVR publishing script
public function DVR():void
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://192.168.172.111/dvr");
}
private function onNetStatus(event:NetStatusEvent):void{
trace(event.info.code);
switch(event.info.code){
case "NetConnection.Connect.Success":
publishCamera();
displayPublishingVideo();
break;
}
}
private function displayPublishingVideo():void {
vid = new Video(cam.width, cam.height);
vid1.x = 10;
vid1.y = 10;
vid.attachCamera(cam);
vid1.width=cam.width;
vid1.height=cam.height;
vid1.addChild(vid);
this.addChild(vid1);
}
private function publishCamera():void {
cam = Camera.getCamera();
mic = Microphone.getMicrophone();
ns = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.attachCamera(cam);
ns.attachAudio(mic);
// Publish the stream to the server
ns.publish("video", "record");
}
Streaming side
public function DVR():void
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://192.168.172.111/dvr");
}
private function onNetStatus(event:NetStatusEvent):void{
trace(event.info.code);
switch(event.info.code){
case "NetConnection.Connect.Success":
displayVideoPlay();
break;
}
}
public function onMetaData(info:Object):void {
trace("metadata:duration = " + info.duration);
stamp = getTimer();
trace("stamp: " + stamp);
duration = info.duration;
}
private function displayVideoPlay():void
{
nsPlayer = new NetStream(nc);
nsPlayer.client = this;
nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nsPlayer.play("video", 0, -1);
vidPlayer = new Video(200,150);
vidPlayer.attachNetStream(nsPlayer);
vidPlay1.width=200;
vidPlay1.height=100;
vidPlay1.x=350;
vidPlay1.addChild(vidPlayer);
this.addChild(vidPlay1);
}
Copy link to clipboard
Copied
In Streaming side script you need to add the timecoord handler as below:
private function displayVideoPlay():void
{
nsPlayer = new NetStream(nc);
//nsPlayer.client = this;
nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
client = new Object();
ns.client = client;
client.onTimeCoordInfo = timeCoordHandler;
nsPlayer.play("video", 0, -1);
vidPlayer = new Video(200,150);
vidPlayer.attachNetStream(nsPlayer);
vidPlay1.width=200;
vidPlay1.height=100;
vidPlay1.x=350;
vidPlay1.addChild(vidPlayer);
this.addChild(vidPlay1);
}
function timeCoordHandler(timeObj:Object):void{
}
Regards,
Amit
Copy link to clipboard
Copied
Thanks for your reply Dear Amith Kumar
but if i use nsPlayer.client=client ; i am unable to access the metadata, if i use nsPlayer.client=this i am able to access the metadata. could i use nsPlayer.client=this; or i must to use nsPlayer.client=client;
Thanks and Regards,
G.Thirumalai murugan
Copy link to clipboard
Copied
If you are using nsPlayer.client = this; then you just need to add the onTimeCoordInfo handler method like onMetaData and nothing else:
private function displayVideoPlay():void
{
nsPlayer = new NetStream(nc);
nsPlayer.client = this;
nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
//client = new Object();
//ns.client = client;
//client.onTimeCoordInfo = timeCoordHandler;
nsPlayer.play("video", 0, -1);
vidPlayer = new Video(200,150);
vidPlayer.attachNetStream(nsPlayer);
vidPlay1.width=200;
vidPlay1.height=100;
vidPlay1.x=350;
vidPlay1.addChild(vidPlayer);
this.addChild(vidPlay1);
}
public function onTimeCoordInfo(info:Object):void {
}
Regards,
Amit
Copy link to clipboard
Copied
Dear Amith Thanks a lot for spending your valuable time to reply me... Could u tell me what we can do in this onTimeCoordinfo what's the need of it. Reply me if you have time im also searching in web for this solution.
Copy link to clipboard
Copied
One of the main use case for OnTimeCoordInfo is basically to synchronize the multi bitrate streams.
So whenever a client plays a stream it gets Absolute-time and the Absolute-time sent to the client for time=0 should be made use of by the client player to seek to the correct point of that stream.
For example, suppose there are three streams A, B, C in MBR and absolute-time values are 0, 10 and 20 respectively. While seeking the stream to say '100' absolute-time value has to be added to get the right data in MBR.
Stream A -> ns.seek(100 + 0);
Stream B -> ns.seek(100 + 10);
Stream C -> ns.seek(100 + 20);
You can get this absolute time as below:
public function onTimeCoordInfo(info:Object):void {
for(var p in info){
trace("onTimeCoordInfo " + p +" : " + info
);
}
- Amit