-
Buffering FLV videos.
Has ANYONE made any use of the buffering functions of FCS?
I posted my problem a couple weeks ago but nobody replied.
I cant get the playback to resume properly after the buffer is exhausted, then filled again.
-
I have no idea, but I'm guessing this could help you out:
http://www.macromedia.com/desdev/mx/.../odopod05.html
Later,
Somar!
-
has anyone tried that Odopod example. i dont think it works properly.
i guess its not really an example...anyone know?
Some of you *must* have made a video player that lets you fast forward and rebuffer and start playing again.
Maybe not...what stage are all of you at in using FCS?
It seems terribly easy to do something big with CFMX, FRemoting and FCS. Anyone working on something good?
-
Buffering the video
I have succesfully done this without much hassel. The Odopod example has some typos in it as well as some structural things that don't work. I think the article was just written quickly and without many quality checks. I have attatched some code that may help out:
serverName="rtmp://prv-flash"; // create connection to server
videoToLoad="corp"; // name of the video to load
totalBuffer=1; // total buffertime
endtime=150; // this is the total number of seconds of the video
nc = new NetConnection();
nc.connect(serverName+"/mxpresentation");
nc.onStatus = function(returnObj) {
// this function checks connection status
if (returnObj.code == "NetConnection.Connect.Success") {
startVideo();
} else if (returnObj.code == "NetConnection.Connect.Rejected") {
gotoAndStop("server busy");
nc.onStatus=null;
} else if (returnObj.code == "NetConnection.Connect.Closed") {
gotoAndStop("closed connection");
}
};
function startVideo() { // function to start video
myInputStream = new NetStream(nc);
vidBoxPlay.attachVideo(myInputStream);
myInputStream.setBufferTime(totalBuffer);
myInputStream.play(videoToLoad);
myInputStream.onStatus = function (infoObject) {
if (infoObject.code == "NetStream.Play.Start" || infoObject.code == "NetStream.Buffer.Empty") {
// below checks for the stream to end or buffer
if (myInputStream.time<endtime) {
buffer_mc._visible=1;
isBuffering = 1;
}else if(myInputStream.time >= endtime) play()
} else if (infoObject.code == "NetStream.Buffer.Full") {
isBuffering =0;
}
}
}
// this returns the percent buffered so that it can
// be displayed graphically
function bufferStatus () {
if (isBuffering){
currentBuffer=myInputStream.bufferLength;
bufferPercent=currentBuffer/totalBuffer;
if (bufferPercent > 1) bufferPercent =1, buffer_mc._visible=0
buffer_mc.bar_mc._xscale=bufferPercent*100;
}
}
pause_btn.onRelease=function (){pauseMovie()} // pauses the movie
play_btn.onRelease=function(){playMovie()} // plays the movie
function pauseMovie () {
myInputStream.pause(true);
}
function playMovie () {
myInputStream.pause(false);
}
Well that's it. If you want it to fastforward and the like you can easily set it to seek to a specific place in your video. I didn't need to with this example but you get the idea.
-
did you experience the problem that i spoke of? when you tested the rebuffering does it start again properly?
i had tried my own code...found Odopod's...which was pretty much the same (i mean the buffering event handler)...i fixed the things that were missing and the slight errors.
have you tested this extensively?
I still had the rebuffering problem.
-
I haven't had any problems with it restarting. It has been working well for me... sorry.
-
I am getting errors with your code. It looks like it is this line of code that is causing the problem but I don't know what you were trying to write.
Code:
if (myInputStream.time buffer_mc._visible=1;
Thanks for the help
-
Ok.. one more try :-)
That if statement should have been this:
if (myInputStream.time < endtime) {
when I cut and pasted it into the window it got rid of my code.
Here it is again:
// create connection to server
serverName="rtmp://flash.server.com";
videoToLoad="corp";
totalBuffer=1;
endtime=150;
nc = new NetConnection();
nc.connect(serverName+"/mxpresentation");
nc.onStatus = function(returnObj) {
if (returnObj.code == "NetConnection.Connect.Success") {
startVideo();
} else if (returnObj.code == "NetConnection.Connect.Rejected") {
gotoAndStop("server busy");
nc.onStatus=null;
} else if (returnObj.code == "NetConnection.Connect.Closed") {
gotoAndStop("closed connection");
}
};
function startVideo() {
myInputStream = new NetStream(nc);
vidBoxPlay.attachVideo(myInputStream);
myInputStream.setBufferTime(totalBuffer);
myInputStream.play(videoToLoad);
myInputStream.onStatus = function (infoObject) {
if (infoObject.code == "NetStream.Play.Start" || infoObject.code == "NetStream.Buffer.Empty") {
if (myInputStream.time < endtime) {
buffer_mc._visible=1;
isBuffering = 1;
}else if(myInputStream.time >= endtime) play()
} else if (infoObject.code == "NetStream.Buffer.Full") {
isBuffering =0;
}
}
}
function bufferStatus () {
if (isBuffering){
currentBuffer=myInputStream.bufferLength;
bufferPercent=currentBuffer/totalBuffer;
if (bufferPercent > 1) bufferPercent =1, buffer_mc._visible=0
buffer_mc.bar_mc._xscale=bufferPercent*100;
}
}
pause_btn.onRelease=function (){pauseMovie()}
play_btn.onRelease=function(){playMovie()}
function pauseMovie () {
myInputStream.pause(true);
}
function playMovie () {
myInputStream.pause(false);
}
-
rBorg,
Did you ever resolve your issue? I am having the same problem and can't seem to figure it out.
-
I created a player that was helped out by hoolios code but I also added functions like fast forward, rewind and a timeline slider. I based my buffering on things I learned form hoolios code. What do need to figure out?
-
JA,
I checked out your player from your other post. I think you may be having the same issue as well. When I played your video...paused it...then played again, it rebuffered which is fine, however it skipped ahead in the video a little bit. This is the problem I am having and I think rborg too.
My problem seems to go even further. Once I resume play my video disappears, then I hear the audio first (after skipping a few seconds) and then the video appears a few seconds after that.
I've seen the Odopod example work. It pauses and resumes exactly in the same spot. I'm not sure how to get there.
I have used the code from the reply's above and also my own with the same result.
If you have any suggestions I'll try it out and let you know how it works.
Cheers
MJ
-
You need to change the "Enhanced Seeking" flag in the Application.xml file on the server where Flashcom is installed. By default this value is set to false. When you set this value to true, the server generates a keyframe on the video at each point of the video where a keyframe does not exists.
Hope this helps
-
I actually tried that but it didn't help. Maybe I set it up wrong, can you see anything wrong with what I have done...
I placed 'application.xml' in my application folder which contained the following code:
------------------------
<?xml version="1.0"?>
<Application>
<StreamManager>
<EnhancedSeek>true</EnhancedSeek>
</StreamManager>
</Application>
------------------------
Does 'enhanced seek' work when using...
myStream.pause(false);
to restart the video. I thought that 'enhanced seek' was for seeking...
myStream.seek
Hopefully I'm wrong. Thanks for your help.
MJ
-
My code disappeared. Here it is, I hope.
--?xml version="1.0"?--
--Application--
--StreamManager--
--EnhancedSeek--true--/EnhancedSeek--
--/StreamManager--
--/Application--
Not sure how to make the xml show up with the tags in, so...
-- = < and </
-
After I made the change on the Application.xml file, I had to restart the server before I got it to work properly.
Also, to answer your question, the enhanced seek flag also works for the pause function.
I hope this helps....
-
I can't believe I didn't try restarting the server!
It works fine now.
Cheers,
MJ
-
blast...
well i knew someone would figure it out.
I guess it must be the server side. I will give it a try. In the meantime i fixed it by seeking back about .0001 seconds or something close to that before resuming play. then it rebuffers correctly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|