<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to Control Video (FLV) without a Component</title>
	<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Wed, 07 Jan 2009 01:21:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: casimara</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-306294</link>
		<pubDate>Wed, 26 Nov 2008 00:23:26 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-306294</guid>
					<description>Hi David,
You've got such great info here.  I found your site while trying to figure out a problem with the &quot;go back to frame 1 after playing a FLV&quot; via the netstream method.  Do you have any idea why the last chunk of code below screws up my playhead positioning?  There is a &quot;play&quot; button on frame 1, and all this code on frame 2:

//--------NETCONNECTION SETUP--------------
var nc:NetConnection = new NetConnection();
nc.connect(null);

//--------NETSTREAM SETUP------------------
var ns:NetStream = new NetStream(nc);

ns.onStatus = function(info) {
	if(info.code == &quot;NetStream.Play.Start&quot;) {
		progressBar.onEnterFrame = videoUpdate;
	}
	if(info.code == &quot;NetStream.Play.Stop&quot;) {
		delete progressBar.onEnterFrame;
	}
}

ns.onMetaData = function(info) {
	ns.duration = info.duration;
}

//--------ATTACHING NETSTREAM--------------
video.attachVideo(ns);

//--------PLAYING EXTERNAL FLV-------------
ns.play(&quot;Settle.flv&quot;);

//------------LOADBAR-------------
loadbar.onEnterFrame = function() {
	this._xscale = (ns.bytesLoaded/ns.bytesTotal)*100;
	if(this._xscale == 100) {
		delete this.onEnterFrame;
	}
}

//------------VIDEO UPDATE-----------
function videoUpdate() {
	progressBar._xscale = (ns.time/ns.duration)*100;
	timecode.text = getTimecode(ns.time);
}

//------------VIDEO SCRUBBER----------
loadbar.onPress = function() {
	progressBar.onEnterFrame = videoScrub;
}

loadbar.onRelease = loadbar.onReleaseOutside = function() {
	progressBar.onEnterFrame = videoUpdate;
}

function videoScrub() {
	var dist:Number = (_root._xmouse-loadbar._x)/loadbar._width;
	ns.seek(Math.floor(ns.duration*dist));
	progressBar._xscale = (ns.time/ns.duration)*100;

	timecode.text = getTimecode(ns.time);
}

playHead.onEnterFrame = function() {
	this._x = Math.floor(progressBar._width + loadbar._x);
}

//--------------This code works but breaks the playhead location---------
ns.onStatus = function(info:Object) {
   if (info.code == &quot;NetStream.Play.Stop&quot;) {
   		gotoAndPlay(1);
    }
	
} 

stop();

Any insight is greatly appreciated.

Best,
casimara</description>
		<content:encoded><![CDATA[<p>Hi David,<br />
You&#8217;ve got such great info here.  I found your site while trying to figure out a problem with the &#8220;go back to frame 1 after playing a FLV&#8221; via the netstream method.  Do you have any idea why the last chunk of code below screws up my playhead positioning?  There is a &#8220;play&#8221; button on frame 1, and all this code on frame 2:</p>
<p>//&#8212;&#8212;&#8211;NETCONNECTION SETUP&#8212;&#8212;&#8212;&#8212;&#8211;<br />
var nc:NetConnection = new NetConnection();<br />
nc.connect(null);</p>
<p>//&#8212;&#8212;&#8211;NETSTREAM SETUP&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
var ns:NetStream = new NetStream(nc);</p>
<p>ns.onStatus = function(info) {<br />
	if(info.code == &#8220;NetStream.Play.Start&#8221;) {<br />
		progressBar.onEnterFrame = videoUpdate;<br />
	}<br />
	if(info.code == &#8220;NetStream.Play.Stop&#8221;) {<br />
		delete progressBar.onEnterFrame;<br />
	}<br />
}</p>
<p>ns.onMetaData = function(info) {<br />
	ns.duration = info.duration;<br />
}</p>
<p>//&#8212;&#8212;&#8211;ATTACHING NETSTREAM&#8212;&#8212;&#8212;&#8212;&#8211;<br />
video.attachVideo(ns);</p>
<p>//&#8212;&#8212;&#8211;PLAYING EXTERNAL FLV&#8212;&#8212;&#8212;&#8212;-<br />
ns.play(&#8221;Settle.flv&#8221;);</p>
<p>//&#8212;&#8212;&#8212;&#8212;LOADBAR&#8212;&#8212;&#8212;&#8212;-<br />
loadbar.onEnterFrame = function() {<br />
	this._xscale = (ns.bytesLoaded/ns.bytesTotal)*100;<br />
	if(this._xscale == 100) {<br />
		delete this.onEnterFrame;<br />
	}<br />
}</p>
<p>//&#8212;&#8212;&#8212;&#8212;VIDEO UPDATE&#8212;&#8212;&#8212;&#8211;<br />
function videoUpdate() {<br />
	progressBar._xscale = (ns.time/ns.duration)*100;<br />
	timecode.text = getTimecode(ns.time);<br />
}</p>
<p>//&#8212;&#8212;&#8212;&#8212;VIDEO SCRUBBER&#8212;&#8212;&#8212;-<br />
loadbar.onPress = function() {<br />
	progressBar.onEnterFrame = videoScrub;<br />
}</p>
<p>loadbar.onRelease = loadbar.onReleaseOutside = function() {<br />
	progressBar.onEnterFrame = videoUpdate;<br />
}</p>
<p>function videoScrub() {<br />
	var dist:Number = (_root._xmouse-loadbar._x)/loadbar._width;<br />
	ns.seek(Math.floor(ns.duration*dist));<br />
	progressBar._xscale = (ns.time/ns.duration)*100;</p>
<p>	timecode.text = getTimecode(ns.time);<br />
}</p>
<p>playHead.onEnterFrame = function() {<br />
	this._x = Math.floor(progressBar._width + loadbar._x);<br />
}</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8211;This code works but breaks the playhead location&#8212;&#8212;&#8212;<br />
ns.onStatus = function(info:Object) {<br />
   if (info.code == &#8220;NetStream.Play.Stop&#8221;) {<br />
   		gotoAndPlay(1);<br />
    }</p>
<p>} </p>
<p>stop();</p>
<p>Any insight is greatly appreciated.</p>
<p>Best,<br />
casimara
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Steve C</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-288511</link>
		<pubDate>Thu, 16 Oct 2008 20:48:00 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-288511</guid>
					<description>Nevermind...I was able to find the solution here: http://www.communitymx.com/content/article.cfm?cid=984BA


Basically just add this to the same frame of actionscript:

ns.onStatus = function(info) {
  if (info.code == &quot;NetStream.Play.Stop&quot;) {
  ns.seek(0);
  }
 }; 

Still, many thanks to David for the great tutorial which has saved me once again!</description>
		<content:encoded><![CDATA[<p>Nevermind&#8230;I was able to find the solution here: <a href='http://www.communitymx.com/content/article.cfm?cid=984BA' rel='nofollow'>http://www.communitymx.com/content/article.cfm?cid=984BA</a></p>
<p>Basically just add this to the same frame of actionscript:</p>
<p>ns.onStatus = function(info) {<br />
  if (info.code == &#8220;NetStream.Play.Stop&#8221;) {<br />
  ns.seek(0);<br />
  }<br />
 }; </p>
<p>Still, many thanks to David for the great tutorial which has saved me once again!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Steve C</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-288490</link>
		<pubDate>Thu, 16 Oct 2008 15:42:31 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-288490</guid>
					<description>Hi David...
Thanks for the great tutorial...just one question:

Is there a way to loop the video?

Normally I would just apply this code to the component on the stage:
on (complete) {
this.autorewind =true;
this.play();
}

However, I cannot apply any code to the empty video player...</description>
		<content:encoded><![CDATA[<p>Hi David&#8230;<br />
Thanks for the great tutorial&#8230;just one question:</p>
<p>Is there a way to loop the video?</p>
<p>Normally I would just apply this code to the component on the stage:<br />
on (complete) {<br />
this.autorewind =true;<br />
this.play();<br />
}</p>
<p>However, I cannot apply any code to the empty video player&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cesar</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263918</link>
		<pubDate>Thu, 04 Sep 2008 16:49:20 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263918</guid>
					<description>Nevermind!  I got it.  I used Jason's solution:

ns.onStatus = function(info) {
if (info.code == NetStream.Play.Stop) {
ns.seek(0);
}
}; 

You have to make sure to put double quotes around NetStream.Play.Stop.
So, do this: if (info.code == &quot;NetStream.Play.Stop&quot;) {

Thanks though
You too Jason</description>
		<content:encoded><![CDATA[<p>Nevermind!  I got it.  I used Jason&#8217;s solution:</p>
<p>ns.onStatus = function(info) {<br />
if (info.code == NetStream.Play.Stop) {<br />
ns.seek(0);<br />
}<br />
}; </p>
<p>You have to make sure to put double quotes around NetStream.Play.Stop.<br />
So, do this: if (info.code == &#8220;NetStream.Play.Stop&#8221;) {</p>
<p>Thanks though<br />
You too Jason
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cesar</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263916</link>
		<pubDate>Thu, 04 Sep 2008 16:42:42 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263916</guid>
					<description>I wasn't complete on what I meant about your solution to the replay.  I got your code to work but it would only replay one time for a total of 2.  I would like the ability to replay inifinitely.

var duration:Number = 0;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachVideo(ns);

if (replay != &quot;true&quot;) {
	ns.play(&quot;nuevo.flv&quot;);
}else{
	ns.pause;
}

ns.onMetaData = function(evt:Object):Void {
  duration = evt.duration;
};
ns.onStatus = function(evt:Object):Void {
  if (this.time &amp;#62; 0 &amp;#38;&amp;#38; this.time &amp;#62;= duration) {
	  var replay = &quot;true&quot;;
	  ns.seek(0);
	  ns.pause();
	  delete this.onStatus;
  }
}

btnPausePlay.onRelease = function() {
  ns.pause();
}</description>
		<content:encoded><![CDATA[<p>I wasn&#8217;t complete on what I meant about your solution to the replay.  I got your code to work but it would only replay one time for a total of 2.  I would like the ability to replay inifinitely.</p>
<p>var duration:Number = 0;<br />
var nc:NetConnection = new NetConnection();<br />
nc.connect(null);<br />
var ns:NetStream = new NetStream(nc);<br />
videoPlayer.attachVideo(ns);</p>
<p>if (replay != &#8220;true&#8221;) {<br />
	ns.play(&#8221;nuevo.flv&#8221;);<br />
}else{<br />
	ns.pause;<br />
}</p>
<p>ns.onMetaData = function(evt:Object):Void {<br />
  duration = evt.duration;<br />
};<br />
ns.onStatus = function(evt:Object):Void {<br />
  if (this.time &gt; 0 &amp;&amp; this.time &gt;= duration) {<br />
	  var replay = &#8220;true&#8221;;<br />
	  ns.seek(0);<br />
	  ns.pause();<br />
	  delete this.onStatus;<br />
  }<br />
}</p>
<p>btnPausePlay.onRelease = function() {<br />
  ns.pause();<br />
}
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cesar</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263912</link>
		<pubDate>Thu, 04 Sep 2008 16:31:34 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-263912</guid>
					<description>David-

First of all, thank you so much!  You have bailed me out more than you know, just never posted.  I'll try to make this 'short and sweet'.  

My problem is the same as Jason Hone had (4 posts up), I would like to restart the video as soon as it completes.  I tried the code that he posted but couldn't get it to work. I also tried your post on it and was also unsuccessful.  Hopefully you can help me out again.

Here is the code:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
videoPlayer.attachVideo(ns);
ns.play(&quot;nuevo.flv&quot;);

ns.onStatus = function(info) {
if (info.code == NetStream.Play.Stop) {
ns.seek(0);
}
}; 
					   
btnPausePlay.onRelease = function() {
  ns.pause();
}</description>
		<content:encoded><![CDATA[<p>David-</p>
<p>First of all, thank you so much!  You have bailed me out more than you know, just never posted.  I&#8217;ll try to make this &#8217;short and sweet&#8217;.  </p>
<p>My problem is the same as Jason Hone had (4 posts up), I would like to restart the video as soon as it completes.  I tried the code that he posted but couldn&#8217;t get it to work. I also tried your post on it and was also unsuccessful.  Hopefully you can help me out again.</p>
<p>Here is the code:<br />
var nc:NetConnection = new NetConnection();<br />
nc.connect(null);<br />
var ns:NetStream = new NetStream(nc);<br />
videoPlayer.attachVideo(ns);<br />
ns.play(&#8221;nuevo.flv&#8221;);</p>
<p>ns.onStatus = function(info) {<br />
if (info.code == NetStream.Play.Stop) {<br />
ns.seek(0);<br />
}<br />
}; </p>
<p>btnPausePlay.onRelease = function() {<br />
  ns.pause();<br />
}
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-233460</link>
		<pubDate>Tue, 29 Jul 2008 15:48:12 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-233460</guid>
					<description>David,

As many have mentioned, your blog is a great resource, thanks for sharing all of this info with us.

I have built a an FLV Player in ActionScript 3.0 using the VideoPlayer class.  Do you have any experience with it?  Do you believe it to be a better alternative than using the low level NetStream implementation?

In order to use the class inside of the Flash IDE without the FLVPlayback component I had to change the ActionScript 3.0 classpath.  It's obvious to me then that Adobe did not intend for us to use it in the way that I have.  However, according to the documentation for the class, it seemed like the best choice to me.

The biggest reason I'm asking is because I've run into a bit of a brick wall when it comes to scrubbing through my videos.  Updating the playhead position on every frame (Event.ENTER_FRAME) does not work very well.  The best implementation I've found is to use a Timer object and update the playhead every half second.

Do you have an thoughts on the subject?  Unfortunately there aren't very many resources for this sort of project out there, so any insight will be appreciated.

Cheers.</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>As many have mentioned, your blog is a great resource, thanks for sharing all of this info with us.</p>
<p>I have built a an FLV Player in ActionScript 3.0 using the VideoPlayer class.  Do you have any experience with it?  Do you believe it to be a better alternative than using the low level NetStream implementation?</p>
<p>In order to use the class inside of the Flash IDE without the FLVPlayback component I had to change the ActionScript 3.0 classpath.  It&#8217;s obvious to me then that Adobe did not intend for us to use it in the way that I have.  However, according to the documentation for the class, it seemed like the best choice to me.</p>
<p>The biggest reason I&#8217;m asking is because I&#8217;ve run into a bit of a brick wall when it comes to scrubbing through my videos.  Updating the playhead position on every frame (Event.ENTER_FRAME) does not work very well.  The best implementation I&#8217;ve found is to use a Timer object and update the playhead every half second.</p>
<p>Do you have an thoughts on the subject?  Unfortunately there aren&#8217;t very many resources for this sort of project out there, so any insight will be appreciated.</p>
<p>Cheers.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Davader</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-185626</link>
		<pubDate>Mon, 19 May 2008 03:03:36 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-185626</guid>
					<description>Hello David
Im new to Flash and actionscript so bare with me, I have a flash site thats 600 x 800, I wish to load a new movie thats a swf that streams a flv, size is 450 x 300 but when ever it loads it plays at 600 x 800. I added --/ import mx.video.*;
my_FLVPlybk.maintainAspectRatio = false;
my_FLVPlybk.width = 450;
my_FLVPlybk.height = 300;
my_FLVPlybk.contentPath = &quot;../video/loves_misfortune.flv&quot;;
--/ into the sctionscript panel to maintain size,

I have a button to open said video with this this action--/
on(release) {
	my_mc.onUnload = function () {
    trace (&quot;onUnload called&quot;);
}
loadMovie(&quot;../swf/movie player.swf&quot;,_root);
}
--/

What I trying to get is, unload current player and load new movie with new size of 450 x 300
But as you can see Im not getting to work, I have other movies loading into player and they size just fine.
Do you think you can help.
Thank you</description>
		<content:encoded><![CDATA[<p>Hello David<br />
Im new to Flash and actionscript so bare with me, I have a flash site thats 600 x 800, I wish to load a new movie thats a swf that streams a flv, size is 450 x 300 but when ever it loads it plays at 600 x 800. I added &#8211;/ import mx.video.*;<br />
my_FLVPlybk.maintainAspectRatio = false;<br />
my_FLVPlybk.width = 450;<br />
my_FLVPlybk.height = 300;<br />
my_FLVPlybk.contentPath = &#8220;../video/loves_misfortune.flv&#8221;;<br />
&#8211;/ into the sctionscript panel to maintain size,</p>
<p>I have a button to open said video with this this action&#8211;/<br />
on(release) {<br />
	my_mc.onUnload = function () {<br />
    trace (&#8221;onUnload called&#8221;);<br />
}<br />
loadMovie(&#8221;../swf/movie player.swf&#8221;,_root);<br />
}<br />
&#8211;/</p>
<p>What I trying to get is, unload current player and load new movie with new size of 450 x 300<br />
But as you can see Im not getting to work, I have other movies loading into player and they size just fine.<br />
Do you think you can help.<br />
Thank you
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-169420</link>
		<pubDate>Thu, 24 Apr 2008 20:22:45 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-169420</guid>
					<description>Jason,

Good job!  Yes, that's one of the ways to do it.  I describe &lt;a href=&quot;http://www.quip.net/blog/2007/flash/actionscript-20/how-to-determine-completion-of-flv&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;another approach elsewhere on this blog&lt;/a&gt;, but your approach is the more elegant.</description>
		<content:encoded><![CDATA[<p>Jason,</p>
<p>Good job!  Yes, that&#8217;s one of the ways to do it.  I describe <a href="http://www.quip.net/blog/2007/flash/actionscript-20/how-to-determine-completion-of-flv" target="_blank" rel="nofollow">another approach elsewhere on this blog</a>, but your approach is the more elegant.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jason Hone</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-163897</link>
		<pubDate>Wed, 16 Apr 2008 09:28:56 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component#comment-163897</guid>
					<description>Hi David

Found code just needed this at end:

ns.onStatus = function(info) {
  if (info.code == &quot;NetStream.Play.Stop&quot;) {
  ns.seek(0);
  }
 };</description>
		<content:encoded><![CDATA[<p>Hi David</p>
<p>Found code just needed this at end:</p>
<p>ns.onStatus = function(info) {<br />
  if (info.code == &#8220;NetStream.Play.Stop&#8221;) {<br />
  ns.seek(0);<br />
  }<br />
 };
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
