根据一些互联网教程的建议,我使用PHP和Flex为FLV Video Player构建了一个简单的服务器-客户端应用程序。我遇到的问题是我无法使用notepad++更改mxml文件中的视频源。如果我运行Flex,源代码可以更改,但这不是一个好主意,因为我想通过这个播放器运行不同的视频。请建议如何使用此Flex视频播放器组件运行不同的视频,因为我的应用程序仅适用于FlexPlayer源代码中给出的视频。也许我不应该对不同的视频源使用这个mxml文件?
<s:VideoPlayer id="Player" left="0" top="0" width="493" height="382" chromeColor="#2875DE"
color="#000000" skinClass="MySkin" source="Video Source/Coldplay - Clocks.flv"/>
</s:Application>
正确,由于您的flex应用程序已编译,您将无法使用它来定义观看哪些电影。
但是,你可以使用其他方法在运行时将数据获取到应用程序中。
例如,你可以在html的参数中指定视频文件,因为你可以在每次运行它之前在记事本或其他文本编辑器中编辑它:
<?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>
在这种情况下,你可以在调用flex应用程序的html中指定它作为flashvar参数。在html页面中查找:
<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>
有意义吗?