Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Start video at 10seconds


Hi everybody and thx a lot to Jeroenwijering !

*I'm looking for a way to point in time in an flv...*
for example can i point in a 30min flv and start it playing at 15min and stop at 20min ?

*total time of the FLV 30min
i just want 5min starting at 15min
Is that possible ?*


I tried via an .asx like that :
------------------------------------------------
bc.. <asx version="3.0">
<entry>
<title>TITLE</title>
<Starttime value="00:15:00" />
<Duration value="00:05:00" />
<ref href="video.flv" />
</entry>
</asx>

------------------------------------------------
But it does not work.

Can someone help me ?

Thx in advance.
Toinan
toinan@toinan.com

28 Community Answers

JW Player

User  
0 rated :

you can use the "scrub" command of the JS-api to move the playhead -
please see these javascript demos on the demopage:
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/javascript.htm
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/snippetplayer.htm

JW Player

User  
0 rated :

Oh yes Andersen,

i've already took a look at those pages, but it does not really what i want.

i want to be able to tell my flv to play just a specifik part of the entire video.
and that script depends on the currentPosition, i want to launch the specific part of the video as soon as the video starts.

like a metafile does it for a windows :
an asx as the one i've shown you above does it for a wmv video.

that's why i was looking for a kind of metafile or script that would do the same with an flv and that beautifuly scripted JW flv player !!

thx again for your answer !

JW Player

User  
0 rated :

I'd like to do this: http://home5.inet.tele.dk/nyboe/flash/mediaplayer/javascript.htm
but only be able to scrub it directly by issuing it through a flashvar, like flashvars="file=this.flv&start=00:05&autostart=true&..."

That way I could use a server side include to set where it starts from - that would be amazing..I've seen it done before for other players, but they generally don't support playlists.

JW Player

User  
0 rated :

Moe.Lester, i've tried your code but that flashvar "start=00:05" is not taken by jw flv player... i won't ask for the player name that does that here, hopping that there is a way to do that or that it's gona be implemented very soon.
--------------------------------------------------------------------------------------------------------------------------------------------------

Is there a way throught javascript to scrub from the begining of the video instead of doing it from the currentPosition as shown on the javascript exemple page ? bc.. http://home5.inet.tele.dk/nyboe/flash/mediaplayer/javascript.htm


*a kind of absolute scrub not relative to my actual position ?*

JW Player

User  
0 rated :

yes, you can scub to an absolute position, like this: sendEvent('scrub',5) - scrubs to the 5th second - added to the demo now

JW Player

User  
0 rated :

hummmm i love you Andersen !! (y)

*Thx a lot !!*

JW Player

User  
0 rated :

hummmm....
last question : is there a way to point in Cuepoints via flashvar or javascript using JWFLVPLAYER ?


As I could not load a metafile that would point in time in my flv or use a flashvar to do it, i was then looking for a way to launch this javascript onload : javascript:sendEvent('jstest','scrub',115)

*here is my code for thoses who could need it : *

bc.. <script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function sendEvent(swf,typ,prm) {
thisMovie(swf).sendEvent(typ,prm);
};

function thisMovie(swf) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[swf];
} else {
return document[swf];
}
};

function createPlayer() {
var s1 = new SWFObject("player700k.swf","jstest","420","290","1");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("autostart","true");
s1.addVariable("file","video.flv");

s1.addVariable("enablejs","true");
s1.addVariable("javascriptid","jstest");

s1.addVariable("width","420");
s1.addVariable("height","290");
s1.addVariable("displayheight","270");

s1.write("container");
};

function andersen(){
createPlayer();
window.setTimeout("sendEvent('jstest','scrub',115)",1000);
};
</script>
</head>
<body onload="andersen()">

<div id="container">This text will be replaced</div>

JW Player

User  
0 rated :

i hav a Jeroenwijering flv fullscreen player,inside a html page,

in that html page one button is there,

that button should be invisible until user click & watch half of the flv movie,

after watching that half of the movie,that html button should be automatically active,

any idea how to do this type of thing using javascript in flash

plz mAIL ME AT neeraj8585@gmail.com

JW Player

User  
0 rated :

Isn't there a step by step guide or solution for a FLV file to play from a point (e.g. 05:00) and then play to a point (e.g. 23.00) by sending flashvars or anything else?

Thanks

JW Player

User  
0 rated :

@Umut DOGAN - you can use the javascript api - http://www.jeroenwijering.com/?item=Javascript_interaction

it is no problem to stop playing at time 23 - but the video must be preloaded to be able to scrub to time 5 and start playing...

please see the source of these demos :

http://home5.inet.tele.dk/nyboe/flash/mediaplayer/snippetplayer.htm
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/previewtest.htm
http://home5.inet.tele.dk/nyboe/flash/mediaplayer/javascript.htm
demopage: http://home5.inet.tele.dk/nyboe/flash/mediaplayer

JW Player

User  
0 rated :

@andersen
thanks for your reply.

it seems that without a flash streaming server it is not possible to have a feature like in the asx files.

For example if i made clips from a 3 minutes video for every 10 seconds, and in every 10 seconds there is a thumbnail. When user clicks 4th thumbnail he/she should start watching from 40th second till end. On the other hand if i made an option to select start and end times, he/she could watch clip of for example 20th and 40th seconds.

But with just a flv player it is not possible.

Am i right?

Thanks... ;)

JW Player

User  
0 rated :

@Umut,

You can use ffmpeg to serve arbitrary chunks of an FLV file.

You could have a playlist with start and end times, or just a start time and play to the end.

You could have an input form where the user could enter a starting and ending time.

ffmpeg can also extract the images from the video for the thumbnails.

If you can run ffmpeg on your server and are interested, I can set up a demo.

JW Player

User  
0 rated :

I know I can scrub to a specified time while a playlist item is already playing, but I want to start playing that item at a specified time. I tried:

bc.. function()
{
sendEvent('playitem','0');
sendEvent('scrub',15)
}


This works only if you click on the link twice (a double click does the trick), but I want it so that you only have to click once and it immediately starts playing from 15 seconds.

Thanks in advance.

JW Player

User  
0 rated :

AJAX, is there more documentation on how to do that (giving the 'start' command) with a Flash Media Server (using FMS3 here)? I tried <start>20</start> in my playlist, but that doesn't do the trick.

JW Player

User  
0 rated :

You must be use <meta rel="start">123</meta>

JW Player

User  
0 rated :

Gloria: Awsome! Thanks!

Now my new problem: I have a playlist of chapters. Basically it's one video but for every chapter i give a different start value. When i click an item in the playlist, the scubber disappears.

I have that same problem when i load a playlist holding multiple instances of the same video, plus a couple of other video's. When i change between playlist items that point to the same video, the scrubber is gone. When i click a different video in the playlist, the scrubber is back. Weird behavior...

JW Player

User  
0 rated :

Hi, I want to stop my video at 15 seconds like in this example: http://home5.inet.tele.dk/nyboe/flash/mediaplayer/snippetplayer.htm

But it doesn't work with my code. My code is pretty messy and long so if someone is willing to check it out and tell me what I'm doing wrong then PLEASE DO! That will be great.

Thanks!

*--EDIT-*-

I found my mistake! My function thisMovie wasn't good!

JW Player

User  
0 rated :

It's me again! Yeah another question...

Is there some reason why (scrub,'15') doesnt scrub scrub exactly at 15 seconds?

It's scrubbing like 3 seconds before...

bc.. *if ((currentState==2) && eval(currentPosition== 0) || eval(currentPosition==1)){

sendEvent('scrub',15)

}*

Thanks!=)

JW Player

User  
0 rated :

You only scrub to keyframe. Make more keyframe, then scrub to shorter time.

JW Player

User  
0 rated :

@newbie87 - what is the point of the eval?

doesnt the combined argument just amount to: bc.. if ((currentState==2)&&(currentPosition<2)) { sendEvent('scrub',15); }
if the purpose is to start at 15 (provided there is a keyframe there) i guess this would be better: bc.. if ((currentState==2)&&(currentPosition<15)) { sendEvent('scrub',15); }
this would effectively prevent the user from playing the first 15 seconds - but to be on the safe side i think bufferlength should then be 15 or a test of the "load" should be made in order to prevent scrubbing ahead of the "load"

JW Player

User  
0 rated :

bc..

JW Player

User  
0 rated :

@andersen
Hum, I think it this doesn't work it jammed the video.

@Gloria
What do you mean I only scrub to keyframe. And how do I make more keyframe...?

JW Player

User  
0 rated :

@newbie87 - sure you are not scrubbing ahead of the load?

did you set the *buffer* to 15 ?
does the video jam if you wait untill the *load* is more than 15 before scrubbing?

keyframes are a sort of anchors or stations in the video - and you can only stop it at these positions -
you will probably have to reencode the video - many encoders have a setting for keyframe frequency and/or position.

JW Player

User  
0 rated :

*if I do :*

bc.. if (typ=='load'){currentLoad=pr1}

if(currentLoad>15){

if((currentState==2)&&(currentPosition<15)){

sendEvent('scrub','15')
}

}

Is it suppose to work? Because it does'nt work for me
What is the load unity?

JW Player

User  
0 rated :

@ newnie87 - *ouch* - this is a lot tougher than anticipated ! - no wonder you got in trouble !

stopping the player at a specific time is no problem - http://home5.inet.tele.dk/nyboe/flash/mediaplayer/snippetplayer.htm

but there are two huge obstacles to starting at a specific time:
the load is measured in percent and the position in seconds -
and it seems to me that the flashvar bufferlength is broken !
(i will file this as a bug report right after posting here)

this makes it difficult to make a general solution - one would have to get the duration and calculate the percentage equal to the start position - if the bufferlength had worked as expected, it would have been a lot easier, as one could then be sure that the playing wouldnt start before the set value was reached. as it is now one has to hardcode the load percentage where the video is to start...

i have made a working demo, see it in action here - http://home5.inet.tele.dk/nyboe/flash/mediaplayer/loadtest.htm bc.. <html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var currentState;
var currentLoad;
var currentPosition;
var loadFlag;

function getUpdate(typ,pr1,pr2,pid) {
if (typ=='load') { currentLoad=pr1; }
if (typ=='state') { currentState=pr1; }
if (typ=='time') { currentPosition=pr1; }

if((currentState<3)&&( ! loadFlag)) {
loadFlag = true;
sendEvent('playpause');
sendEvent('playpause');
}

if((currentPosition<15)&&(currentLoad>90)&&(loadFlag)) {
sendEvent('scrub','15');
sendEvent('playpause');
}
};

function sendEvent(typ,prm) { thisMovie("playerID").sendEvent(typ,prm); };

function thisMovie(movieName) {
if(navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
};

function createPlayer(theFile) {
loadFlag=false;

var s1 = new SWFObject("mediaplayer316.swf","playerID","480","360","9");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","true");

s1.addVariable("width","480");
s1.addVariable("height","360");

s1.addVariable("file", theFile);

s1.addVariable("enablejs","true");
s1.addVariable("javascriptid","playerID");

s1.write("placeholder");
}
</script>
</head>
<body onLoad="createPlayer('video.flv')">

<div id="placeholder">
<a href="http://www.macromedia.com/go/getflashplayer">get flash</a>
to see this player.
</div>
<br>
<a href="javascript:createPlayer('video.flv')">Grass by night</a><br>

</body>

JW Player

User  
0 rated :

Thanks for all the work! I'll check this out.

JW Player

User  
0 rated :

co wy piszecie

JW Player

User  
0 rated :

You can't do this:bc.. sendEvent('playitem','0');
sendEvent('scrub',15);
for several reaasons:

1) The player won't have finished loading the file when the sendEvent() is received, so it won't have any effect.

2) The player can't scrub into a portion of a file that has not been downloaded yet.

You could set the bufferlength for 15 seconds, then check to see if load=100 before sending the sendEvent('scrub', 15).

Better yet, use an RTMP server like Red5 that can receive the 'start' command ( only from a playlist ) and will then start serving the file at 15 seconds.

Or...

Use ffmpeg to serve the file on-demand. Then you can start and stop anywhere that you want, although the video won't start until a keyframe is received, so you shuld make sure that you have keyframes every 3-5 seconds if you want to start on those boundaries.

This question has received the maximum number of answers.