none
I can play a SWF video but not a Flash Video - why? RRS feed

  • Question

  • With the help of this forum members and google search i've done the following part

    Code Snippet

    Imports AxShockwaveFlashObjects
    Public Class Form1

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim axShockwaveFlash As New AxShockwaveFlash
            axShockwaveFlash.Location = New System.Drawing.Point(10, 10)

            Me.Controls.Add(axShockwaveFlash)
            'me.Show(); Avoids InvalidActiveXStateException.

            axShockwaveFlash.Movie = "D:\\movie.swf"
            'it is important to set Size after specifying Movie property
            'if Size is specified before, it is ignored
            axShockwaveFlash.Size = New System.Drawing.Size(270, 250)
            axShockwaveFlash.Play()
        End Sub

    End Class


    using this I can play a .swf video "D:\\movie.swf" - located  in my hard drive...

    but the issue is to play a .flv file i.e. a flash video file...

    when i'm replacing the path with - "D\\flashvideo.flv" - the out put is getting blank - with a white backgruond.....

    Can any one help me out??

    Atanu

    Thanks and Regards

    Wednesday, January 23, 2008 7:20 AM

Answers

  • Like I pointed out already in the other post about this topic (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2714808&SiteID=1) you cannot just play a FLV file with the flash axtivex control.

    I've been reading the tutorial now in detail, and what you have to do is, you have to create a wrapper SWF-file. this swf has to hold some actionscript code to be able to dynamicly load the FLV file by sending the path as an xml-string to the SWF file.

    Sounds confusing and weird, but that is just what Adobe wants. They actually don't want us to play FLV movies unless you have a copy of Adobe Flash to create this SWF wrapper movie.

    Maybe you find this wrapper movie somewhere on the net.

    So the steps you have to do in simple words:

    • Create a swf file with some functionality to be able to load a flv file (lets call it flvplayer.swf with the actionscript funtion loadFLV to load the FLV file)
    • Add the Flash ActiveX component to your form like you already did
    • Set the movie of your control to flvplayer.swf
    • Call the actionscript function of the flvplayer.swf thru your activex-control to load the flv movie into the swf movie

    Code Snippet

    axShockwaveFlash.LoadMovie(0, "D:\\flvplayer.swf")

    axShockwaveFlash.CallFunction("<invoke name=""loadFLV"" returntype=""xml""><arguments><string>" + flvFileName + "</string></arguments></invoke>")

     

     

     

    Argl... that's just what I thought... and that's why I don't like those Adobe guys, and that's why I stick with VB instead of getting an actionscript expert Wink
    Wednesday, January 23, 2008 2:47 PM

All replies

  • Like I pointed out already in the other post about this topic (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2714808&SiteID=1) you cannot just play a FLV file with the flash axtivex control.

    I've been reading the tutorial now in detail, and what you have to do is, you have to create a wrapper SWF-file. this swf has to hold some actionscript code to be able to dynamicly load the FLV file by sending the path as an xml-string to the SWF file.

    Sounds confusing and weird, but that is just what Adobe wants. They actually don't want us to play FLV movies unless you have a copy of Adobe Flash to create this SWF wrapper movie.

    Maybe you find this wrapper movie somewhere on the net.

    So the steps you have to do in simple words:

    • Create a swf file with some functionality to be able to load a flv file (lets call it flvplayer.swf with the actionscript funtion loadFLV to load the FLV file)
    • Add the Flash ActiveX component to your form like you already did
    • Set the movie of your control to flvplayer.swf
    • Call the actionscript function of the flvplayer.swf thru your activex-control to load the flv movie into the swf movie

    Code Snippet

    axShockwaveFlash.LoadMovie(0, "D:\\flvplayer.swf")

    axShockwaveFlash.CallFunction("<invoke name=""loadFLV"" returntype=""xml""><arguments><string>" + flvFileName + "</string></arguments></invoke>")

     

     

     

    Argl... that's just what I thought... and that's why I don't like those Adobe guys, and that's why I stick with VB instead of getting an actionscript expert Wink
    Wednesday, January 23, 2008 2:47 PM
  • Well - Thanks a lot....

    "I stick with VB instead of getting an actionscript expert"

    Really, After getting in touch of such a VB expert, i'm feeling good.......

    I am a novice in this technology, and the kind of support i've got especially from u and from other forum member is amazing....

    Please suggest:

    I changed the code to

    Code Snippet

    axShockwaveFlash.LoadMovie(0, "http://pyg.keonox.com/tests/flash_flv_player/flvplayer.swf")

            flvFileName = "D:\\flashvideo.flv"
            Try
                axShockwaveFlash.CallFunction("<invoke name=""loadFLV"" returntype=""xml""><arguments><string>" + flvFileName + "</string></arguments></invoke>")
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

            axShockwaveFlash.Play()


    Though the path for swf player is http://pyg.keonox.com/tests/flash_flv_player/flvplayer.swf ( A remote  one )  but thats not a problem

    the line 

    axShockwaveFlash.CallFunction("<invoke name=""loadFLV"" returntype=""xml""><arguments><string>" + flvFileName + "</string></arguments></invoke>")

    is giving an exception that is

    ---------------------------
    ShockWave
    ---------------------------
    System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.   at ShockwaveFlashObjects.IShockwaveFlash.CallFunction(String request)   at AxShockwaveFlashObjects.AxShockwaveFlash.CallFunction(String request)   at ShockWave.Player.PlayFile_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\Desktop\ShockWave\ShockWave\Player.vb:line 43
    ---------------------------
    OK  
    ---------------------------

    Am i needed to add any COM reference??

    Thank you again......

    Friday, January 25, 2008 8:34 AM
  • Good to know that there is such a movie out there on the net. You have to register the COM function before you use it. I will try to translate the C# code I found to VB and use the movie you use.

    Are you sure that they also called their function loadFLV or is movie some you created yourself and is this your webspace?

    I will keep you up to date,

     

    Cheers Daniel

     

    Friday, January 25, 2008 8:57 AM
  • OK folk.

    Seems your file has a different functionality than the file I was using.

    First of all you need to download the SWF to your local disc, it will not work remote, because your flv movie is also local. It will only work remote if your flv movie is remote as well, because the remote file will not have access to your local disc!

     

    So what I did using the file you provided:

     

    Code Snippet

    axSWF.LoadMovie(0, "d:\temp\flvplayer.swf")

    axSWF.FlashVars = "file=" + flvFileName

    axSWF.Play()

     

     

    Well, this is much simpler than expected before...

     

    Have fun, Daniel

    Friday, January 25, 2008 9:43 AM
  • OOOOOOOOOOOOOOOOO.............Its working..........

    Its really a great fun..........

    That code was so simple..........Thanks Daniel once more.....

    Its great......

    Linning up more of these kind of assignment to have more fun........

    A new nerd is ready with lots of question for these forum members.............

    Cheers

    Atanu



    Friday, January 25, 2008 12:11 PM
  • Hi, I'm having the same error message when calling following line of code:

    Error Message: "Error HRESULT E_FAIL has been returned from a call to a COM component."
    Code:   axShockwaveFlash.CallFunction(@"<invoke name=""loadFLV"" returntype=""xml""><arguments><string>barsandtone.flv</string></arguments></invoke>");

    One of the post above mentioned to register COM function before using it. But I can't figure how to do it.
    Any Suggestion?

    (By the way, I'm doing this in WPF project. I think it should be same)


    --------------- Below is the original code -----------------

    // Create the interop host control.

    WindowsFormsHost host = new WindowsFormsHost();

    // Create the ActiveX control.

    AxShockwaveFlash axShockwaveFlash = new AxShockwaveFlash();

    // Assign the ActiveX control as the host control's child.

    host.Child = axShockwaveFlash;

    // Add the interop host control to the Grid

    // control's collection of child controls.

    this.MainGrid.Children.Add(host);

    axShockwaveFlash.Location = new System.Drawing.Point(0, 0);

    axShockwaveFlash.LoadMovie(0, @"D:\WPFSandbox\flv\player.swf");

    axShockwaveFlash.SetVariable("quality", "Low");

    axShockwaveFlash.ScaleMode = 0;

    axShockwaveFlash.AllowScriptAccess = "always";



    axShockwaveFlash.SetVariable("file", @"D:\WPFSandbox\flv\barsandtone.flv");

    //axShockwaveFlash.SetVariable("autostart", "true");



    //axShockwaveFlash.FlashVars = @"file=D:\WPFSandbox\flv\barsandtone.flv&autostart=true&fullscreen=true&controlbar=none&repeat=always&stretching=fill";

    axShockwaveFlash.CallFunction(@"<invoke name=""loadFLV"" returntype=""xml""><arguments><string>barsandtone.flv</string></arguments></invoke>");

    axShockwaveFlash.Play();

    • Edited by Phillox Friday, November 14, 2008 6:48 AM
    Friday, November 14, 2008 6:42 AM
  • Even if I do like below: 

    axShockwaveFlash.FlashVars = @"file=D:\WPFSandbox\flv\barsandtone.flv&autostart=true&fullscreen=true&controlbar=none&repeat=always&stretching=fill";

    Something weird happened. The FlashVars value is empty even after executed above line of code.
    So far, I manage to play swf file only. No luck for flv file yet.  > . <

    Any help is appreciated.

    Friday, November 14, 2008 6:48 AM
  • I'm having the very same problem when I try to run Beezmath or any other example of C# / Flash integration. Does anyone have a clue??? Thanks in advance

    "Error HRESULT E_FAIL has been returned from a call to a COM component."
    Code:   axShockwaveFlash.CallFunction(@"<invoke name=""loadFLV"" returntype=""xml""><arguments><string>barsandtone.flv</string></arguments></invoke>");


    Friday, May 1, 2009 4:51 PM
  • @ Cassio, you are posting to thread that was already marked as answer and 5months old, you should try to read each post maybe it will help or start new thread on your own.
    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Friday, May 1, 2009 5:21 PM
  • @"file=D:\WPFSandbox\flv\barsandtone.flv&autostart=true&fullscreen=true&controlbar=none&repeat=always&stretching=fill";

    axShockwaveFlash.CallFunction(

     

    @"<invoke name=""loadFLV"" returntype=""xml""><arguments><string>barsandtone.flv</string></arguments></invoke>");

    axShockwaveFlash.Play();

    there are simple errr


    axShockwaveFlash.CallFunction(@"<invoke name=""loadFLV"" returntype=""xml""><arguments><string>barsandtone.flv</string></arguments></invoke>/0");

    Sunday, May 10, 2009 4:50 PM
  • Hello,

    I'm trying to implemet the simplest flv player, for beginning...

    And also have the same problems, as it seems...
    I can play swf files but not flv.

    what does it mean:
    • "Create a swf file with some functionality to be able to load a flv file (lets call it flvplayer.swf with the actionscript funtion loadFLV to load the FLV file)"

    I guess this file not really swf clip, but contains some code - actionscript?
    Can you help with it? Example of such file will be very usefull.

    Thanks.
    Monday, May 18, 2009 7:21 AM
  • evgeni_57 i uploaded completed applicaiton  for you


    it's flv player developed by c#

    http://rapidshare.com/files/234380023/FlashExternalAPI.rar.html

    Monday, May 18, 2009 12:54 PM
  • evgeni_57 i uploaded completed applicaiton  for you


    it's flv player developed by c#

    http://rapidshare.com/files/234380023/FlashExternalAPI.rar.html

    Thank you very much!
    Your help was very usefull!

    But now I'm stuck with some othe problems - like pause/stop playback, getting movie's time.... Zooming too... but it is less important...

    As I understand all this functionality should be added in player.swf  file, right?
    If yes - what dev tool do you advise to use? Any manual with simple examples?

    Thanks a lot once again!
    Tuesday, May 19, 2009 3:01 PM
  • Dear evgeni_57 and __ulas___       
    Please help me!  
    Can you give me the sample code, because i can't write the player.swf  
    Thank you
    • Edited by acherley Friday, August 21, 2009 8:27 AM
    Friday, August 21, 2009 8:21 AM
  • Hi acherley,

    Indeed standard Flash ActiveX can't play flash video and so it requires flash coding.

    If you need a quick result I would suggest to use 3rd party component like F-IN-BOX (f-in-box.com/dotnet/ - a .net version) or similar.

    Hope this helps!

    Wednesday, August 27, 2014 8:43 AM