Create My Own Universal Flash Player

I would like to know to create a youtube like flash player. I basically want to embed a swf object and then feed different videos to it. Right now, I made a xml driven video player, however, I would have to create a new swf and xml list for each video I want to embed on my site. This is a real drag and pain. What is the procedure to make a universal player like youtube.
FYI: I can't use flow player because it uses java script and I would like the pages I make on my site to be able to share on facebook.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you explain why you are saying this???
   I would have to create a new swf and xml list for each video

adrian7474Author Commented:
Ok, so I created a flash file called "myplayer" and in it I have a flv playback component that calls an xml file(mylist) that feeds it the video source(mp4 file) and plays it. If I embed this swf (myplayer.swf) on my web page, all is good. However, now I create another page on my site and want to embed myplayer.swf on it, however, I would like the video to play a different video. If I change the xml file that feeds it, it will also change the original page too. So now I have to duplicate the fla(myplayer2.swf) file, change the actionscript to call different xml(myplayer2) every time I need to add a new page with this custom player i created. Huge pain.
Does this help explain why?
I guess I don't understand this line...
   If I change the xml file that feeds it, it will also change the original page too.

What do you really mean by 'different xml'???  Is it just two different XML file with the same structure or are they different in structure as well???
I am thinking you should really lock the structure of the XML and just specify the name of the video in it and it should work fine on displaying different video files with no problem???

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

adrian7474Author Commented:
I will try one more time.
Player.swf => Player.xml => video,mp4
(ie Player.swf calls Player.xml which has video file path in it. )
Example xml structure:

Now, I WANT to use my player for all videos I put on my site and have it be dynamic (LIKE YOUTUBE).
Meaning, if player.swf was on two different pages, but each page has a different video file associated with it, how would i do this with out having to create a new swf, new xml file???

Hm...  That does not tell me why it is changing the original page...  Do you have an example page up that I can take a look???

adrian7474Author Commented:
No, I haven't posted anything yet, I am in the r & d stage of mysite. Besides, wouldn't the fla file be a better example choice? I feel you are not understanding what I am trying to accomplish. I am just frustrated at this point, I have explained this several times already.
One last time.

If I embed one swf container that uses xml to get the data onto two different html pages and change the xml file data, the player swf will change on both pages. However, I want to use a different video for each page, but use the same swf player, how would I accomplish this?
Okay...  If I have two player.swf embedded in one HTML file...  Both of the player.swf files are the same one which is linked to different XML sources, ie the first player.swf is provided to read youtube.xml and the second player.swf is provided with vimeo.xml file...

To my knowledge, that setup should never affect each other, but you are saying it does...  That's why I said I'd like to see it in action because I can diagnose why it might be happening without going through the complicate script...  

If you feel like we are not communicating well, you are feel free to click on the Request Attention link on top of this page to request to close this topic and open a new one...  I wouldn't be offended if you do that...

adrian7474Author Commented:
Ok, almost there. How do i have one swf player to be used on several pages all containing different videos. Like youtube has one player that serves millions of different videos.
Just feed the different XML source file per embed...  
Can you post your HTML code you are using???

Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Let me see if I got this right...

You have Player.swf.

Somewhere in that file you have some line similar to this:

var urlRequest:URLRequest = new URLRequest("PLAYLIST.xml");
var xmlLoader:URLLoader = new URLLoader(urlRequest);
xmlLoader.addEventListener("complete", xmlLoaded);

If so, that first line is the issue. Every time it will try to load from the same "playlist" (same xml), so creating a new playlist means generating a new swf with something like "OTHER_PLAYLIST.xml" as the target, thus the hassle.

It can be avoided if you send that parameters via HTML and catch it on the swf. Kinda like this:


Also, as you can see, I'm using swfObject (an old version due to several reasons, but hey, it works), you can download that specific version from here:

Now, the only thing you'd need to change is the HTML for the swf to load different XML files.

Good luck.

<script type="text/javascript" src="./swfobject.js"></script>
<div id="flashcontent"></div>
  <script type="text/javascript">
    // <![CDATA[
    var so = new SWFObject("Player.swf", "Player", "550", "400", "9", "#FFFFFF");
    so.addParam("wmode", "transparent");
    so.addVariable("targetXML", "SOME_PLAYLIST.XML");
    // ]]>

var targetXML:String = root.loaderInfo.parameters.targetXML;
var urlRequest:URLRequest = new URLRequest(targetXML);
var xmlLoader:URLLoader = new URLLoader(urlRequest);
xmlLoader.addEventListener("complete", xmlLoaded);

Open in new window

adrian7474Author Commented:
Sorry for the delay. This sounds about what I would want, only I can't get it going. I looked at a bunch of documents and tutorial online, but can't figure out to get it to work with video fed by xml. I followed this example on adobe:
and tried to get it to work with xml and can't.
I applied your code example and i get this error:
1120: Access of undefined property xmlLoaded.
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Check the following package, it includes source code (fla), two sample videos, two "playlists" (xml files), two html pages that each call a different "playlist".

Try opening the HTMLs to see it in action. If you have any questions, I'll gladly answer.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adrian7474Author Commented:
Thanks so much. This is great. I would like to be able to have this be embeddable. Meaning so i could use a url like this
<embed src="" flashvars="video_id=123456789" width="300" height="200" type="application/x-shockwave-flash" />
Would this be possible? I will ask this in another question too, cause you deserve credit for this (so look out for it and hopefully you can help solve this one:) )
thanks again,
adrian7474Author Commented:
Awesome this expert was
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Glad to help :)

And yeah, a tag like that seems fine to me, but we can get into detail if you like. (Although, what we're doing with swfObject is embedding it, though we don't get the tag like that, so you can't move it to somewhere else).

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.