FLVPlayback component AS3 detect when there is no source file?

Hi all

I have an AS3 FLVPlayback component on stage playing movies from a local folder. There are 22 films in the folder and it chooses the one he will play random mathRandom function where it concatenates .flv to one that has been generated (1.flv, 2.flv and so on).

For ease of maintenance, I decided to control the set of random numbers with a variable that is defined in an external text file, so if someone adds new movies all that person needs to do is go in the external text file and the increase in the value of the variable to reflect the number of films in the folder (and any new film should follow the naming convention that is number.flv). When I'm in control of the files is no problem, but I can't looking for a way to detect if the number generated film exists or not (let's say the random number is 10 so 10 flv should be played, but 10 flv does not exist in the folder). I just want to add an if statement that handles only if there is no such thing as the chosen film look for another, but I can't seem to find a property that I can use to test this.

My FLVPlayback instance is named myMoviePlayer. I tried:

myMoviePlayer.totalTime: this always returns NaN, that the film exists or not.

myMoviePlayer.preferredWidth: this always returns-1, that the film exists or not.

myMoviePlayer.state: the return of loading, if film still exists or not.

I tried all other read-only properties defined for FLVPlayback, but they always return the same value that the film exists or not. So I tried to trace these properties but with myMoviePlayer.source and that always returns an error: «Property may not set a static String type reference»

In any case, this is my code as it is right now I'm trying to solve this problem:

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES; 
loader.addEventListener(Event.COMPLETE, loading); 
loader.load(new URLRequest("movies.txt"));
var extNumber;
function loading (event:Event):void { 
          extNumber = loader.data.nMovies;
          ran = genRandomNum(1, extNumber);
          trace(ran + ".flv");
          myMoviePlayer.source = 25 + ".flv"; //I actually have extNumber defined as 22 in the movies.txt file so 25 should force an error
          trace(myMoviePlayer.totalTime);
          if (myMoviePlayer.totalTime > 0) {
                    trace ("It lives!")
          }
}
myMoviePlayer.addEventListener(Event.COMPLETE, playAgain);
stage.displayState = StageDisplayState.FULL_SCREEN;
myMoviePlayer.fullScreenTakeOver = false;
stage.scaleMode = StageScaleMode.NO_SCALE;
function playAgain(e:Event):void {
          trace("starting over");
          trace(extNumber);
          ran = genRandomNum(1, extNumber);
          trace(ran);
          myMoviePlayer.source = ran + ".flv";
          myMoviePlayer.play();
}
var ran:Number = genRandomNum(1, extNumber);
function genRandomNum(minNum:Number, maxNum:Number):Number {
          return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);  
}

Here are some classes that check if a file exists on a server:

loading http://www.kirupa.com/forum/showthread.php?328651-checking-to-see-if-a-File-exists-Before-

Tags: Adobe Animate

Similar Questions

  • CS6 bridge crashing when there's a GIF file in the folder.

    Out of the box, Adobe Bridge was "randomly" crash when opening files.

    To determine the cause of the accident, I created a new folder and drag the files one by one. among the other issues that crashed the bridge.

    All this works end until I drag a GIF file, and then it just stopped responding and immediately blocked.

    I tried with several different GIF files, and they seem to all be blocked the bridge.

    Ideas of all parameters to prevent this?

    I, of course, need to work with gifs, so those filtering is not a solution.

    Thank you!

    Oh wow, I found a solution!

    Instead of using Adobe Bridge CS6 (64-bit), I used the non - 64-bit Adobe Bridge CS6 version, and these GIFs work now.


    It's really weird because I have a 64 bit OS and I use other products Adobe 64-bit without problem.

    Thanks for the help guys, I guess that the 64 bit version has some problems.

  • [Issue] FLVPlayBack component in visualizzation browser

    Hi all,

    I need help abput FLVPlayback component:

    I created a project with several clip of 3D animation, each of them containing a FLVPlayback component.

    When I run this project in a stand alone flashplayer or an empty HTML page everything works fine, when I run what it inside the site target Web as IE or Firefox, the FLVPB does not appear is appearance of control (like volume, play/pause and so on) when a mouse over/out event product.

    Can someone give me a help? Thank you

    Looks like your original problem was one of multiple paths... a pretty common issue. And Yes, you can reuse the skin on several pages, as long as the path is correct. So when used on different pages, just be sure that the used path is correct for this page.

    As a small reminder on multiple paths:

    Path problems

    Almost always, when it works on the local computer and not by the server, it's a path problem.
    You can put your related Flash files into whatever the desired files, they don't have to be at the root. But if they stick to that worked, then you know that the question was a path problem.
    Remember that the paths become compared to the Web page on which these Flash files are used. Thus, for example, that if your .swf is located in the folder data/flash and you use this .swf on a Web page under the root, you are indeed, remove this data/flash .swf and put them in the root. So if the .swf is responsible for all associated files (xml, etc.), the path used inside the .swf in the .xml file must be compared to its new location in the root and back down into flash/data. This is true even if when you test the .swf by itself, it can be inside the flash/data and work very well, as compared to its location, the path is very good, they are in the same folder. But if this same path is used when the .swf is placed on a folder page level two upward, the relative path has changed, the old "same folder" path will not work.
    So just remember that you use an address to the final location and you can put the files where you want.
    Best wishes
    Look for the video
    www.cidigitalmedia.com

    Good luck to you!

    Adninjastrator

  • How to unload a FlvPlayback component

    What are the steps to download a flv file after clearing the necessary memory used for loading and also to remove the component FLVPlayback.

    This is the code I used to create FLVPlayback component and setting its source.

    public var m_flvPlayer:FLVPlayback;

    m_flvPlayer = new FLVPlayback();

    m_flvPlayer.AutoPlay = false;

    m_flvPlayer.source = "FileName.flv".

    addChild (m_flvPlayer);

    Attached to unload the actions button

    m_flvPlayer.stop ();


    m_flvPlayer.autoRewind = true;

    m_flvPlayer.getVideoPlayer (0). Close()

    removeChild (m_flvPlayer); Clears FLVPlayback component.

    Are there any other important step we need to do for safe unloading of the FLVPlayback component?

    use:

    public void init(sFileName:String):void {}
    trace (FLVPlayback.version);

    m_flvPlayer.activeVideoPlayerIndex = 1;
    m_flvPlayer.visibleVideoPlayerIndex = 1;
    m_flvPlayer.AutoPlay = true;
    m_flvPlayer.source = sFileName;
    }
    public function unINI (): void {}
               
    m_flvPlayer.stop ();
    m_flvPlayer.autoRewind = true;
    m_flvPlayer.closeVideoPlayer (1);

    MyComObj.removeChild (m_flvPlayer);
    m_flvPlayer = null;

    MyComObj.nextFrame ();

    }

  • How to get the NetConnection off an in AS3 flvplayback component?

    http://www.Flashcomguru.com/index.cfm/2009/8/14/FLVPlayback-obtain-NC-reference

    I followed the above example in AS2, but only get the error:

    Call to a possibly undefined method getNetConnection through a reference with static type fl.video:INCManager.


    Here is my code:

    this.addEventListener (Event.ENTER_FRAME,
    function() {}
    If ((nc = player.ncMgr.getNetConnection ())! = undefined)
    {
    trace (NC);
    }
    });

    Someone knows how to do it in AS3?

    Hello

    Drag the flvplayback component on the stage and 'vidplayer' name in the properties panel. Then, you can use the following code example:

    import flash.utils.setInterval;
    import flash.utils.setTimeout;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.events. *;

    Import fl.video.FLVPlayback;
    Import fl.video.VideoPlayer;
    Import fl.video.VideoEvent;

    import flash.display.MovieClip;

    VideoPlayer.iNCManagerClass = fl.video.NCManagerNative;
    vidplayer.isLive = false;
    vidplayer.isDVR = false;
    vidplayer.source = "rtmp://localhost/vod/sample";

    var videoplayer:VideoPlayer;
    var flvplayback:FLVPlayback;
    FLVPlayback = FLVPlayback (this.getChildByName ("vidplayer"));
    VideoPlayer = flvplayback.getVideoPlayer (0);
    setTimeout (initMonitor, 5000);

    function initMonitor (): void
    {
    If (videoplayer.netStream! = null)
    {
    trace ("video plays!");
    If (VideoPlayer.NetConnection)
    {
    trace ("Got NetConnection!");
    }
    }
    on the other
    {
    trace ("Main.as:" + "not connected to FMS yet - try again...")
    setTimeout (initMonitor, 5000);
    }
    }

    Kind regards

    Amit

  • Add time to the FLVplayback component

    Hi everyone, I'm using the FLVplayback component for a project im doing. I want to add that the time elapsed and time remaining on the controls. I don't really want to create my own controls, as im happy with the flv playback component. The FLV playing in the component files is external and is loaded in via as3

    Is there a quick and easy way to do this?

    See you soon
    Dan

    use:

    Import fl.video.VideoEvent;
    Import fl.video.MetadataEvent;

    var fullDuration:String = "";
    function metadataReceivedF(e:MetadataEvent):void {}
    fullDuration = prettyTime (vidPlayer.metadata.duration);
    };
    function updateF(e:VideoEvent):void {}
    var paTime = vidPlayer.playheadTime;
    If (fullDuration! = "") {}
    time_txt. Text = prettyTime (vidPlayer.playheadTime) + "/" + fullDuration;
    }
    };

    vidPlayer.addEventListener (MetadataEvent.METADATA_RECEIVED, metadataReceivedF);
    vidPlayer.addEventListener (VideoEvent.PLAYHEAD_UPDATE, updateF);

    function prettyTime(timeinSeconds:Number):String {}
    var seconds: Number = Math.floor (timeinSeconds);
    var minutes: Number = Math.floor (seconds/60);
    var hours: Number = Math.floor(minutes/60);
       
    seconds, % = 60;
    % of minutes = 60;
       
    var sec: String = seconds.toString ();
    var min:String = minutes.toString ();
    var hrs:String = hours.toString ();

    While (sec.length< 2)="">
    s = '0' + seconds;
    }
    While (min.length< 2)="">
    min = "0" + min;
    }
    While (hrs.length< 2)="">
    h = "0" + hrs;
    }
    return h + ":" + min + ":" + seconds;
    }

  • FLVPlayback component look at a multiple of flv

    Hi I have set up an instance of flvplayback and when a button is clicked I want to load in and read a new flv

    I have the following code:

    Add the FLVPlayback (required for playback of flv) class
    Fl.video import. *;

    Create a new FLVPlayback object to contain the video
    var myVideo:FLVPlayback = new FLVPlayback();
    set the width of the video
    myVideo.width = 544; set the width of the video
    myVideo.height = 304; set the height of the video
    myVideo.x = 200; set the horizontal position video
    myVideo.y = 88; set the vertical position video
    Set the video source to the current video stored in the variable myFlv
    myVideo.source = myFlv;
    put the video on the stage
    addChild (myVideo);

    It all works very well and the first flv loads and plays great no problem

    I have a button on stage that when you click on I want to load in a new video and play

    Ive tried many things, but the new video not loaded

    function to call when computer button is clicked
    function onComputerClick(event:MouseEvent):void {}

    myFlv = "dse_computerVideo.swf";//set the video to load.

    removeChild (myVideo);
    trace ("video deleted");
    myVideo.source = myFlv
    addChild (myVideo);
    trace ("added videos");

    }

    Ive tried to use myVideo.contentPath, but it produces the following error

    1119: access of property may be undefined contentPath through a reference with static type fl.video:FLVPlayback.

    I can't believe this is not possible.

    I know how use netstream but unless there is a way to use skins with it's is not the way I want to go.

    been Googling all day and not find a souloution if ideas or things to try would be greatly appreciated

    Why you try to play a swf file in a flvplayback component?

  • The overview/poster set for the flvplayback component

    I have been customizing the flvplayback component and have encountered a problem. So far, I created a custom look for the flvplayback component, with a play overlay button that loads the FLV file dynamically from flashvars successfully. Now, I'm trying to load in a static image that takes until the video is played. I look around the internet and in the Adobe forums, but have not found what I'm looking for. I thought that maybe the preview in the AS3 flvplayback component would help, but it won't apparently.

    I was thinking myPlayer.source = "image.jpg"; but then how to change what is the source, once someone clicks on the video? I also found fl.video.VideoEvent, but I don't know how I can use this to set the image as a source, so that someone presses the play button, or until the video plays (notice that I use a play button on overlay that appears whenever the movie is paused, so once the video starts to play (, I would not want the static preview image to find once again... until someone clicks the play button of any kind)

    Ideas or meanings is greatly appreciated.

    I joined code how I am dynamically loading the FLV right now.

    The preview of the component FLVPlayback-is only a placeholder for design - which will not get exported in the final swf file unfortunately. The class itself does not posterframe features. What you need to do is to load your posterframe using the class loader as:

    var pfContainer:MovieClip = new MovieClip();
    addChild (pfContainer);
    var pf:Loader = new Loader();
    PF. Load (new URLRequest ('posterframe.jpg');
    pfContainer.addChild (pf);

    Next, you need to define an EventListener to your FLVPlayback instance that removes the Posterframe when the video starts to play:

    myPlayback.addEventListener (VideoEvent.PLAYING_STATE_ENTERED, removePF);
    {removePF(e:Event):void}
    removeChild (pfContainer);
    }

    If you want to have the Posterframe reappear on break, you could hide the pf instead of remove and set up a second EventListener for VideoEvent.PAUSED_STATE_ENTERED.

  • FLVPlayBack component

    Hello

    I am trying to get a handle on the FLVPlayBack component.

    I have the instance of the component drugs at my stage.

    When I set the contentPath of the file name, we'll call it ald.flv and test the movie on my development machine, the video plays.

    However, when I download the file swf and flv on my live server for quality controls, it does not play, even if the swf and flv are in the same directory, both on our development box and our direct box.

    In addition, if I set the content to an http address path to point to the FLV on our direct box, the video does not, on our development or our direct box.

    Now, the propaganda on the Adobe website, they claim "It Just Works". Well, it 'Just' does not work.

    Can anyone point us in the direction of this ' work '?

    Thank you very much.

    GN

    leatherjeep wrote:
    > :) OHHHHHHHHH!
    >
    > Can you tell me all references about these MIME configurations? I am
    > familiar with them, and I know how to configure them on our web server.
    > but there is really not much sense to me that my server would require no
    > more change - I think I understand the video plays
    > the Flash Player on the client machine - with no impact on the
    > web server set up.
    >
    > If you have a url to a post here in the discussions on this issue which
    > would be much appreciated.
    >
    > I'll try your theory of video import tomorrow... Alas, I'm
    > time to access today.
    >
    > Thanks for your help so far.

    I had the same problem. They added this mime type
    The mime type that was added was: video/x-flv

    Hope this helps

  • How do I detect when a write of correlated digital output is completed

    Hi LabGurus

    I'm trying to synthesize a SPI signal on the output lines digital stamped usin a M - Series USB Daq (6225, 6229).

    I wrote most of the code and have developed the following problems:

    When I use 'finished samples' to the clock mode, the waveform it is limited to the size of the buffer on board. There is no specific error, but the output waveform is strangely truncated States 1027. The nidaq buffer is fixed and changing the buffer on Board has no effect.

    When I use continuous samples, there is no way to detect when the task is finished 'Really' (I can clarify in the last round of data is transferred to the device, but not when he was timed out of the unit).

    "Task Daqmx is over" and "Daqmx Wait for completion" give no idea.

    I detect when the last USB device transfer is completed using a write property node Dqmx and comparing 'written total samples' at the 'current write Position.

    The function works as much as I leave long enough so that the task is completed. In almost a fixed delay is not acceptable.

    Timmar,

    For the finite method, have you tried to change the value of "samples per channel" on the VI of Timing DAQmx?  It's what you define for your task to know how many points to wait at the exit.  The default value is 1000.  I hope this helps.

    Kind regards

    Brian T

    Technical sales engineer

  • Detecting when Bluetooth is disconnected

    Hello

    I have a camera I'm trying to connect with my BlackBerry using Bluetooth.

    I am able to connect using the Connector.open (info, Connector.READ_WRITE);

    I can also read and write using the input and the output stream.

    However, I must be able to detect when the port is disconnected from the remote device. I was thinking of using BluetoothSerialPortListener. To use this I try to connect to the device using this method:

    listener = new MyBluetoothListener();  
    
    _serialPort = new BluetoothSerialPort(info[i].toString(), BluetoothSerialPort.BAUD_9600, BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8 | BluetoothSerialPort.DATA_FORMAT_PARITY_NONE | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1, BluetoothSerialPort.FLOW_CONTROL_NONE, 2048, 2048, listener);
    

    This doesn't seem to work. The above call works fine and I get not all exceptions. However, I didn't also get the recall of deviceConnected() my interlocutor.

    I see the following in the console output, and nothing else after that:

    BT: allocSerialPort 81159234
    BT: sdpAddRecord
    BT: allocSdpAttributeData

    Is there something I'm missing here?

    To summarize, I have two questions:

    1. Why isn't the connection using BluetoothSerialPort to work?

    2. assuming I can't that work is there a way I can detect a lag when you use the Connector.open () method?

    Thanks in advance for your help.

    I connect to a Bluetooth device using code very similar to yours, with two exceptions:

    (1) you use info [i] m:System.NET.SocketAddress.ToString () as the first parameter, I just use the equivalent of the info [i]

    (2) I use BluetoothSerialPort.BAUD_115200,

    The listener receives disconnects because I expect.

    The messages that I see when you debug this re as follows:

    BT: allocSerialPort 814ee52c
    BT: BTEVENT_LINK_CONNECT_CNF
    NET. RIM. Bluetooth: DC00
    BT: BTEVENT_LINK_POLICY_CHNG received
    NET. RIM. Bluetooth: EC00

    This test has been done on a 8900 4.6.1.199 is running.

    I hope this helps.

  • How to detect when a screen is navigated away from

    How can I detect when a screen is navigated away from?

    I can override onClose to run code when the user clicks the back button, is there a similar method that is executed when a screen is navigated away from independently to his by the user or the application itself?

    Since the control screen while application of the changes, you should be able to do it for most of the changes in your code.  I'm not aware of a tote place that you can do.  onObscured is called to the things that don't take you away from the screen.

    The only exception is if your username use switch application.  In this case turn off in the Application is called, perhaps this treatment can inform the active screen that something has changed.

  • Detect when a NavigationPane or a Page Gets the focus (after closing leaves) in QML

    Hello world

    Is there a way of QML to detect when a NavigationPane {} (or a {Page} it) Gets the focus?  At the close of a sheet, I want to call a function within this NavigationPane (which is a separate QML file).  After reviewing the documentation, I saw nothing...

    Thank you!

    Too bad.  Leaf has a slot of onClosed I can use.

  • DxDiag has detected that there is a problem accessing Direct3D

    I'll have a directly question X

    Hello

    I have a laptop Compaq CQ62 with Windows 7 64 bit.
    He has a Mobile Intel 4 series video card
    I have Direct X 11 is installed
    However, Direct X seems to give me problems.
    All my programs video game including games crash at launch.
    I went to Dxdiag to understand the question, but when I run Dxdiag it gives me the following error:
    ' DxDiag has detected that there is a problem accessing Direct3D the.
    last time that this program has been used. You want to bypass Direct3D this time? »
    If I hit 'Does NOT' crash DxDiag if I type 'YES' Direct 3D and Texture AGP become "not available".
    I tried uninstalling and reinstalling, but it was without result. Can anyone help please?

    Hello

    1 did you do changes on the computer before the show?
    2. What games you try to play?

    Method 1:
    You can upgrade the graphics card drivers and check:

    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    Method 2:
    You can check the link provided and check:
    http://Windows.Microsoft.com/en-us/Windows7/diagnosing-basic-problems-with-DirectX

    Method 3:
    You can also perform a clean boot and check if it helps:
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Note: after a repair, be sure to set the computer to start as usual as mentioned in step 7 in the Knowledge Base article.

    Method 4:
    You can see the supplied knowledge base article and check:
    DirectX is properly installed on your computer
    http://support.Microsoft.com/kb/256182

    Also check this link for more information:
    Game hangs or quits unexpectedly
    http://support.Microsoft.com/kb/303032

  • How to detect when a page is in sight with jQuery or javaScript?

    Is it possible a detect when a page is in sight? Currently, it seems that my document ready function is called when the page is the next or previous page and the current page. This is called two times... there at - it a reliable way to detect this?

    I came across this a lot. first thing is that when you look at a particular page, DPS is cached the pages around it, all around him, so it brings cached the top, right, bottom and left pages, which will throw things and play videos and what not.

    Here is the workaround to get it to only when launch in sight. set the time of reading automatic (I guess that's an overlay "webcontent") seconds a.125. It will start the clock only when the page (diamonds) is in sight.

    I don't know if theres an easier way, but it's like I do and it works.

Maybe you are looking for

  • Satellite A200-1AX where can I get battery 12

    Hello I have a simple question about the batteries on these laptops.I'm looking to buy a battery 12 cells for this model. Toshiba BG (Bulgaria) said that there is no battery 12 cells laptop model Satellite...Somehow I do not have them. Could someone

  • HP 15 f024 wm energystar: problems with lock screen. (and ICP account)

    OK, so I recently had to replace my hard drive on my pc, so I reinstalled windows, do not use the default that came with my pc. So I took it to a repair store to do this. They have set up a default account for me. When I got my pc back, I logged on m

  • Scaling background Bitmap, 9900 vs 9700

    App looks on the 9900, but of course, the 9700 has a different screen and my bitmaps were created to adapt to the 9900. I checked the other threads, but all they advise to make is to use the method. scaleInto(), who does not work for me, as shown: Bi

  • Read a file in the

    do a how to play the file on blackberrry I tried to play, but his does not

  • I can't use my mouse Logitech M310 with Win 8

    I went to Logitech and downloaded Setpoint from Logitech, what they are saying is that the pilot mouse, but win 8 still does not recognize the mouse. The USB port recognizes data glue so it works.