# how to get video duration in Play command

**URL:** <https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678>\
**Category:** Wowza Streaming Engine\
**Created:** [September 7, 2009, 3:03pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678 "2009-09-07T15:03:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 7, 2009, 3:03pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/1 "2009-09-07T15:03:07Z")

</div>

Hi,

I am working on video mixing with rtmp video streaming. in which i want a video duration which is send by client side script to the wowza streaming server.

after getting the time duration of movie i shall make a break point in which we have to add ads in each interval(means breakpoint).

My Code is:

```auto
public void play(IClient client, RequestFunction function,
			AMFDataList params){
		
		File folder = new File("C:/Program Files/Wowza Media Systems/Wowza Media Server Pro 1.7.2/content/ads");
		File[] listOfFiles = folder.listFiles();
		int cont = listOfFiles.length;
		Random r = new Random();
		int randint = r.nextInt(cont);
		
		String adname = listOfFiles[randint].getName();
		String adsurl = "ads/"+adname;
		String videoname1 = getParamString(params, PARAM1);
		String start1 = getParamString(params, PARAM2);
		
		String length1 = getParamString(params, PARAM3);

		[B]System.out.println("Movie length: "+length1);[/B] // is not working 

		/*DateFormat dateFormat = new SimpleDateFormat("mm:ss");
		Date date = new Date();
		String t = dateFormat.format(date);*/
		
		AMFDataList customDataList = new AMFDataList();
        customDataList.add("play");
        customDataList.add(0.0);
        customDataList.add("null");
        customDataList.add(adsurl);
     /* customDataList.add("Extremists.flv"); */
        customDataList.add(new AMFDataItem(0));
        customDataList.add(new AMFDataItem(-1)); // 10,000 milliseconds (10 seconds)
        customDataList.add(new AMFDataItem(true));

        ModuleCore.play(client, function, customDataList);
        

        
        customDataList.set(PARAM1, new AMFDataItem(videoname1));
        customDataList.set(PARAM2, new AMFDataItem(0));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));

        this.invokePrevious(client, function, customDataList);
        ModuleCore.play(client, function, customDataList);
}
	

```

The value of length1 is comming “null” on console.

if i print the value of videoname1, the it prints.

please suggest me a right way to do that.

thanks

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 7, 2009, 12:01pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/2 "2009-09-07T12:01:31Z")

</div>

Make sure the client-side play command includes duration. If you don’t it will be null in the server-side play command:

> netstream.play(“somevideo.flv”,0,50);

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 7, 2009, 12:53pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/3 "2009-09-07T12:53:42Z")

</div>

If you do not provide the optional arguments of the play command, such as length, it will be null on the server-side. You can use whatever value you want in the server-side command, but if you want to get it from the client-side play command you have to send it.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 7, 2009, 1:06pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/4 "2009-09-07T13:06:00Z")

</div>

You need to do this in the actionscript. Edit the FLA.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 7, 2009, 1:32pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/5 "2009-09-07T13:32:34Z")

</div>

It is probably called player.fla and is probably in the same location as player.swf.

You need Flash CS3 or CS4 to edit FLA files. You can buy it directly from Adobe or look for a reseller. Adobe also has a 30 day trial you can use.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 8, 2009, 11:33am UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/6 "2009-09-08T11:33:51Z")

</div>

Asheesh,

Those two server-side lines are getting the 2nd and 3rd optional arguments of the client-side NetStream.play command, which happens in the Actionscript of JW Player. If these optional arguments are omitted in the Actionscript, the values will be null on the server.

netstream.play(“Extremists.flv”); // this is a simple play command.

netstream.play(“Extremists.flv”, 10,20); // this includes start (10) and length (20).

You have to download the JW Player source code, which includes player.fla and all the actionscript files that make up JW Player. The HTML code of player.html is just the container for the Flash application (JW Player). Working on Wowza server-side modules without having a handle on the client-side Actionscript of the player is like trying to drive a car while sitting in the trunk.

Richard

---

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 7, 2009, 6:11pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/7 "2009-09-07T18:11:19Z")

</div>

Is there any other way

for example when print the video name like

```auto
System.out.println(videoname1);

```

then it is displaying the video name but when i print the length of video, it does not.

please give me the solution on play command which you have provided to me in java.

Please give me the solution which is in Play command of java or html code, from where flv file is mentioned.

last time you give me same code.

But i am not understanding that where and in which file i have to edit it.

could i not get time duration of video from

```auto
String length1 = getParamString(params, PARAM3);

```

Thanks:)

---

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 7, 2009, 6:30pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/8 "2009-09-07T18:30:38Z")

</div>

yes i am sending it by html code, but it is not display on console

when i print from

```auto
System.out.println(length1);

```

[HTML]

[/HTML]

🙂

Thanks

---

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 7, 2009, 6:50pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/9 "2009-09-07T18:50:40Z")

</div>

which one FLA file? and where it could be store?

By the way i was try to edit examples\ServerSideModules\client\MyFirstModule.fla but i couldn’t open.

Two more question i have? That

1. How the player get the total time duration of video if i am not giving the video time duration. and how the wowza server knows time duration of video if i am not give the time.

2. How the time duration is loged in log file with the name of the video and many more details are also loged.

Thanks:)

---

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 8, 2009, 11:21am UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/10 "2009-09-08T11:21:29Z")

</div>

Hi Richard,

there is no any player.fla file. when i download the flv player then i have these files below.

1. player-viral.swf

2. preview.jpg

3. readme.html

4. swfobject.js

5. video.flv

6. yt.swf

that’s it.

and please give me the answer of these question also.

Two more question i have? That

1. How the player get the total time duration of video if i am not giving the video time duration. and how the wowza server knows time duration of video if i am not give the time.

2. How the time duration is loged in log file with the name of the video and many more details are also loged.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![asheesh\_khare](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@asheesh\_khare](https://community.wowza.com/u/asheesh_khare)\
**Post date:** [September 8, 2009, 4:47pm UTC](https://community.wowza.com/t/how-to-get-video-duration-in-play-command/33678/11 "2009-09-08T16:47:11Z")

</div>

Hi Richard, good morning please tell me for what purpose these two

bold variables are in play function:-

As you given me before few day’s,

```auto
public void play(IClient client, RequestFunction function,
			AMFDataList params) {
		
	String videoname = getParamString(params, PARAM1);
    [B]String start = getParamString(params, PARAM2);[/B]
    [B]String length = getParamString(params, PARAM3);[/B]
		
	AMFDataList customDataList = new AMFDataList();
        customDataList.add("play");
        customDataList.add(0.0);
        customDataList.add("null");
        customDataList.add("Extremists.flv");
        customDataList.add(new AMFDataItem(0));
        customDataList.add(new AMFDataItem(10000)); // 10,000 milliseconds (10 seconds)
        customDataList.add(new AMFDataItem(true));
        ModuleCore.play(client, function, customDataList);
        
        getLogger().info("second play");
        customDataList.set(PARAM1, new AMFDataItem("videoname"));
        customDataList.set(PARAM2, new AMFDataItem(0));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));
        ModuleCore.play(client, function, customDataList);
        getLogger().info("third play");
        customDataList.set(PARAM1, new AMFDataItem("Extremists.flv")); 
        customDataList.set(PARAM2, new AMFDataItem(10000));
        customDataList.set(PARAM3, new AMFDataItem(-1));
        customDataList.set(PARAM4, new AMFDataItem(false));
        
        ModuleCore.play(client, function, customDataList);
	}

```

Thanks…
