Search code examples
c#.netmedia-playerrtmp

Play FLV data synchronously


I am just investigating http://www.broccoliproducts.com/softnotebook/rtmpclient/rtmpclient.php RTMP client code. And it is working fine so it gets data and saves the FLV file locally.

The code is pretty simple. So my questions are:

1. Is it possible to play this streaming synchronously? (okay with some delay because of the caching) (I've tried to open writing file via VLC but it is busy...)

2. Any clue how to implement it?

!!! It is not any kind of advertisement of this project! I just need to create some RTMP Player in WPF.


Solution

  • A generic post until you provide some additional requirements.

    Inside of Flash you'd create a button, then implement the following ActionScript.

    on (press) {
        fscommand("Variable1", "Variable2");
    }
    

    Then inside of Visual Studio you need to add the COM Object reference for Shockwave Flash Object. You'll need to ensure that you embed is set to true.

    Now inside Visual Studio you should be able to go to Properties and find fscommand which will allow you to physically connect the value from the Flash Movie.

    AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEvent

    That will collect your variables inside of Flash. You'd simply use e.command and e.arg for example to have the collected item to do something. Such as...

    lbl_Result.Text="The " + e.args.ToString() + " " + e.command.ToString()+ " was clicked.";
    

    And boom your now transmitting your Flash movie's data from Flash into Visual Studio. That is quite simple, quite straight forward.

    This will allow your C# application to actually inherit and utilize your Flash Video.

    Things to Consider:

    • Make sure that you've set embed to true. That is what will physically hold all the Path References within your Flash Object. Otherwise it may call an invalid path.

    Additional Help for Reference:

    1. Inside your project open Solution Explorer.
    2. Right Click on Reference and Add Reference.
    3. Go to COM Object.

    These are the objects available:

    • Shockwave ActiveX
    • Flash Accessibility
    • Flash Broker
    • Shockwave Flash

    The above solution will let you actually use Flash within it's native environment your just simply passing variable data or controls you'd like implemented into C# this way. This way you can actually use RTMP straight to Flash. Your C# application will just expose the Flash Object.

    That is a generic approach, when you provide some extra information I'll update to try and assist you better. There are also libraries such F-In-The-Box, LibRTMP, which may also help.

    The above is quite Generic like I stated; but it will invoke whatever quality you noted in your Flash Video Object; then your C# can simply adjust them like:

    <% MyYoutubeUtils.ShowEmebddedVideo("<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/gtNlQodFMi8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/gtNlQodFMi8&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>") %>
    

    Or...

    public static string ShowEmbeddedVideo(string youtubeObject)
    {
        var xdoc = XDocument.Parse(youtubeObject);
        var returnObject = string.Format("<object type=\"{0}\" data=\{1}\"><param name=\"movie\" value=\"{1}\" />",
            xdoc.Root.Element("embed").Attribute("type").Value,
            xdoc.Root.Element("embed").Attribute("src").Value);
        return returnObject;
    }
    

    Which you can find the thread here: Additional Embed Instructions and Details.

    That is how you could put your Flash into C#, there are ways to also output your C# to Actionscript. But without more details on what your trying to do I can't really do more then these generic responses.

    Please keep in mind, this is on the assumption your trying to store the FLV within your applications, or aggregate data from C# to Flash. I'll need more detail to assist further. I'm not quite sure why C# is required and what your trying to actually do.