non-autoplay

  • mgugly
  • Newbie
  • Newbie
  • mgugly
  • Posts: 5

Post 3+ Months Ago

I followed a tutorial to make flash video player. However, the code has the video autoplay. This would prove to be annoying to my guests, so is there any code that would prevent this? Would you need to see the code i am using to help or no?

thank you for your help.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

nahhh .. we are geeks ... :D
we need no codes :D

Icecold could help ya , he feels the code heheehe

I would explain what should U do but you sound like no programmer at all so , Send the code buddy !... !
  • mgugly
  • Newbie
  • Newbie
  • mgugly
  • Posts: 5

Post 3+ Months Ago

HERE IS WHAT IM USING:

//--------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 == "NetStream.Play.Start") {
progressBar.onEnterFrame = videoUpdate;
}
if(info.code == "NetStream.Play.Stop") {
delete progressBar.onEnterFrame;
}
}

ns.onMetaData = function(info) {
ns.duration = info.duration;
}

//--------ATTACHING NETSTREAM--------------
video.attachVideo(ns);

//--------PLAYING EXTERNAL FLV-------------
ns.play("video.flv");

//------------REWIND BUTTON----------------
rewind.onRelease = function() {
ns.seek(0);
}

//------------PLAY PAUSE TOGGLE-------------
playPause.onRollOver = function() {
if(this._currentframe == 1) {
this.gotoAndStop("pauseOver");
}
else {
this.gotoAndStop("playOver");
}
}

playPause.onRollOut = function() {
if(this._currentframe == 10) {
this.gotoAndStop("pause");
}
else {
this.gotoAndStop("play");
}
}

playPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop("playOver");
ns.pause(true);
}
else {
this.gotoAndStop("pauseOver");
ns.pause(false);
}
}

//------------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);
}

//------------TIME CODE----------
function getTimecode(theTime) {
var t:Number = Math.round(theTime);
var min:Number = Math.floor(t/60);
var sec:Number = t%60;
var s:String = "";
if(min < 10) {
s += "0";
}
if(min >= 1) {
s += min.toString();
}
else {
s += "0";
}
s += ":";
if(sec < 10) {
s += "0";
s += sec.toString();
}
else {
s += sec.toString();
}
return s;
}

//-----------AUDIO CONTROLS----------
this.createEmptyMovieClip("vidSound",2);
vidSound.attachAudio(ns);
var vSound:Sound = new Sound(vidSound);
vSound.setVolume(75);

volScrub._xscale = 75;

volBottom.onPress = function() {
adjustSound();
this.onMouseMove = adjustSound;
}

volBottom.onRelease = volBottom.onReleaseOutside = function() {
delete this.onMouseMove;
}

function adjustSound() {
var dist:Number = Math.floor(((_root._xmouse-volBottom._x)/volBottom._width)*100);
if(dist >= 0 && dist <= 100) {
volScrub._xscale = dist;
vSound.setVolume(dist);
}
}
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

im not sure but it looks like its this
Code: [ Select ]
ns.play("video.flv");


you can add that code to the play button ...

again im not sure how the play and pause button are set to work but this should give u the idea try the following

cut ns.play("video.flv"); from your code and add it to the play and pause function //
e.g

Code: [ Select ]

playPause.onRelease = function() {
if(this._currentframe == 10) {
this.gotoAndStop("playOver");
ns.pause(true);
}
else {
this.gotoAndStop("pauseOver");
ns.pause(false);
ns.play("video.flv");
}
}
  1. playPause.onRelease = function() {
  2. if(this._currentframe == 10) {
  3. this.gotoAndStop("playOver");
  4. ns.pause(true);
  5. }
  6. else {
  7. this.gotoAndStop("pauseOver");
  8. ns.pause(false);
  9. ns.play("video.flv");
  10. }
  11. }
  • mgugly
  • Newbie
  • Newbie
  • mgugly
  • Posts: 5

Post 3+ Months Ago

Thank you so much classified, that worked! However, the way this is set up is that it has the play and pause buttons in the same spot. So for example when your playing it it says pause, and when its paused it says play. Well it now thinks that it is initially playing so it has the pause button out when its not playing right away. how would i fix this? Sorry, i am no coder, i like to make things look nice (design) but when it comes to coding im a fish out of water.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

I think your problem is that your just not telling the pause/play button which state it should use. So if you add this line to your script

Code: [ Select ]
playPause.gotoAndStop("pauseOver");


You should be good to go.

your existing code with the line added...

Code: [ Select ]
//------------PLAY PAUSE TOGGLE-------------

playPause.gotoAndStop("pauseOver");

playPause.onRollOver = function() {
  1. //------------PLAY PAUSE TOGGLE-------------
  2. playPause.gotoAndStop("pauseOver");
  3. playPause.onRollOver = function() {
  • mgugly
  • Newbie
  • Newbie
  • mgugly
  • Posts: 5

Post 3+ Months Ago

Wow, i really cant put into words how thankful i am; thank you to you both, you guys know your stuff.
  • mgugly
  • Newbie
  • Newbie
  • mgugly
  • Posts: 5

Post 3+ Months Ago

I am sorry for posting twice but there seems to be a problem that i didnt expect from this. It appears that the player is not buffering the video untill the user presses play. This isnt good because it sometimes catches up to itself in the begining, or when the site is having bandwidth issues the buffer never fully recovers and the video keeps hitting it. Sometimes the video is buffered at it simply studders like crazy. This was not an issue untill i did the code modifications located above. I have the player running at http://www.mellowgamers.com (not a plug i swear, it just so happens to be the place where its at). Does anyone understand why this would be happening?

thanks again, this forum is a big help.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

hmm you could try to trick it by adding the play command back into the code (leave it on the button) and then pause it right after that. I don't know if that will work or not.

Code: [ Select ]
//--------PLAYING EXTERNAL FLV-------------

ns.play("video.flv");
ns.pause();
  1. //--------PLAYING EXTERNAL FLV-------------
  2. ns.play("video.flv");
  3. ns.pause();


seems like a kind of stupid way to do that but if it works...
Otherwise I'd have to do some research on the NetStream object. I wonder if there's another way to call the video instead of the play("file.flv") way
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Hmmm what do you know the Netstream object seems to support a buffer time command. If you don't set it the default is 0.1 seconds. So if the above is not working (or seems like a really stupid solution) try this

Code: [ Select ]

//--------ATTACHING NETSTREAM--------------
video.attachVideo(ns);
ns.setBufferTime(3);
  1. //--------ATTACHING NETSTREAM--------------
  2. video.attachVideo(ns);
  3. ns.setBufferTime(3);


I added the
Code: [ Select ]
ns.setBufferTime(3);


where the 3 is the number of seconds of video to buffer before playing. The only problem with this is it may be ignored if you aren't using a true streaming server.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.