开发者

Flex-load different videos in Video Player component

开发者 https://www.devze.com 2023-03-21 00:52 出处:网络
As some Internet tutorial suggested I\'ve built a simple server-client application for FLV Video Player using PHP and Flex. The problem I encountered is that I can\'t change the source of the video in

As some Internet tutorial suggested I've built a simple server-client application for FLV Video Player using PHP and Flex. The problem I encountered is that I can't change the source of the video in the mxml file using Notepad++. The source could be changed if I run Flex but It's not a good idea because I want to run different videos through this player. Please suggest how to run different videos with this Flex Video Player component because my application works only for this given in the source of FlexPlayer.mxml-maybe I shouldn't use this mxml file for the different Video Sources?

<s:VideoPlayer id="Player" left="0" top="0" width="493" height="382" chromeColor="#2875DE"
    color="#000000" skinClass="MySkin" source="Video Sou开发者_JS百科rce/Coldplay - Clocks.flv"/>    
</s:Application>


Correct, since your flex app is compiled, you won't be able to use it to define which movies to watch.

You can however use other alternative methods of fetching data into your app at runtime.

For example, you can specify the video file in a parameter in the html because you CAN edit this in notepad or another text editor before you run it each time :

<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" >

<s:VideoPlayer id="Player" left="0" top="0" width="493" height="382" chromeColor="#2875DE"
               color="#000000" skinClass="MySkin" source="{this.parameters.videoFile}"/>    

</s:Application>

In this case, you would specify it in the html that calls your flex app as a flashvar param. Look for this in the html page :

    <script type="text/javascript">
        // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. 
        var swfVersionStr = "10.2.0";
        // To use express install, set to playerProductInstall.swf, otherwise the empty string. 
        var xiSwfUrlStr = "playerProductInstall.swf";
        var flashvars = {};
        flashvars.videoFile = 'Video Source/Coldplay - Clocks.flv';  // specifying video here
        var params = {};
        params.quality = "high";
        params.bgcolor = "#ffffff";
        params.allowscriptaccess = "sameDomain";
        params.allowfullscreen = "true";
        var attributes = {};
        attributes.id = "scratch";
        attributes.name = "scratch";
        attributes.align = "middle";
        swfobject.embedSWF(
            "scratch.swf", "flashContent", 
            "100%", "100%", 
            swfVersionStr, xiSwfUrlStr, 
            flashvars, params, attributes);
        // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
        swfobject.createCSS("#flashContent", "display:block;text-align:left;");
    </script>

Make sense?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号