I have a flash video player and I am just testing to see if I can use jquery/javascript to load that player in. I am trying to make it so that I can load different players in when I need to. Anyone have any ideas on this or know if it is possible? I know my code is wrong but I don't know how else to illustrate what I want to do.
If I take the below code and simply paste it into the html of the page on startup (without trying to use javascript or jquery to load it) then my video will work fine.
$('#container').html('<div class="test"></div><script> \
/* <![CDATA[ */ \
flowplay开发者_如何学Goer(".test", "player/player.swf", { \
clip: { \
bufferLength: "0", \
autoPlay: true, \
autoBuffering: true, \
scaling: \'scale\', \
url:\'video_handler.php?file=somefile\' \
}, \
}); \
/* ]]> */ \
<\/script>');
SWFObject
http://code.google.com/p/swfobject/
SWFObject is a JavaScript based flash embedding API supplying a markup based approach and a method that relies on JavaScript.
By using the supplied code generator and javascript files, it takes a few clicks to create an copy/paste-able block of code to add to your page.
The library will handle everything you would require; such as flash button prompt for those without Flash installed and a simplified bridge for javascript to flash communication.
This is seemless to the end user and developer alike and allows the freedom to manipulate the HTML/JS without resorting to republishing your flash work.
This API is so useful it is hosted on Google Ajax Libraries http://code.google.com/p/swfobject/wiki/hosted_library and modern flash IDE's leverage this code and apply this API to the published content rather than the original propriety convalescent code.
This is useful as you will now have the ability to apply your player at any time to the DOM, simply by referencing the correct JavaScript. As an example:
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
</script>
As you can see - this makes our life almost worth living. I understand the embed code could be more verbose, this is the essence of requirement.
Hope it helps.
flowplayer
provides a javascript library to play flash videos, you can use it like below instead of appending the markup in your question.
IF you have any question related to flowplayer
, I can help you.
$(function(){
$('#container').html('<div class="test"></div>');
flowplayer(".test", "player/player.swf", {
clip: {
bufferLength: "0",
autoPlay: true,
autoBuffering: true,
scaling: 'scale',
url:'video_handler.php?file=somefile'
},
});
});
精彩评论