Oct. 21, 2009Edward Spiegel
I am setting up a page that uses css to stylize the playlist. I am running into a problem. I need to set up some eventListeners -- which can't be done until the player has been fully-instantiated. Normally, I just have a playerReady function in my html page to handle that.
The problem I have is that the javascript files provided by lontailvideo to enable playlist stylizing via css define playerReady. I don't want to alter the code in the .js files they supply because the eventListener setup will vary from page to page.
Any ideas on how I can have playerReady defined in my html page without interfering with the playerReady defined in the longtailvideo .js files
Thanks,
Edward
p.s. I searched through the forum and couldn't find a solution.
Oct. 21, 2009hobbs
You don't need playerReady() at all. It's just a convenience function.
If you want to add Listeners as soon as the player is ready, it's best to check for the availability of the playlist because you can't do anything until the player has finished loading and indexing the playlist.
A simple loop to get the player reference object, then the playlist — repeat if it fails — is all you need.
Oct. 22, 2009Edward Spiegel
Thanks.
Won't this hold up the loading of the rest of the page if for some reason the player is being slow about being instantiated/downloaded?
I suppose I have no choice if there is no alternative. I was hoping that there was some mechanism I didn't know about to pass playerReady up a chain of inheritance.
Oct. 22, 2009lost
If you are embedding your Flash content the right way — using swfobject v2.2, nothing will be held up.
Oct. 22, 2009Zachary Ozer
Try something like this:
try {
var myReady = playerReady;
} catch (err){
}
playerReady = function(obj) {
// Insert your code here
try {
myReady(obj);
} catch (err){
}
}
Oct. 23, 2009Edward Spiegel
Thanks Zachary.
Lost, you mention swfobject 2.2. Is version 2.2 really recommended? It seems like version 1.5 is used by most of the examples on the lontailvideo web site and I have seen a number of bug reports from people reporting that they are having problems with version 2.2 that they didn't have with version 1.5.
Oct. 23, 2009hobbs
swfobject v2.2 is MUCH better than SWFObject in many ways.
Visit the documentation at http://code.google.com/p/swfobject/wiki/documentation to see why.
The only reason that anyone is having trouble is because they didn't read the documentation.
We've been using swfobject v2.x for a year and a half as evidenced by this thread http://www.longtailvideo.com/support/forum/JavaScript-Interaction/9028/SWFObject-2-0
(If you know my style of code, you'll see it there.)
I'm about done helping anyone using SWFObject v1.5 or the object/embed methods because they are so problematic.
Also, there's this...
The advantages of using swfobject v2.x loaded from Google's CDN:
Loading from Google AJAX Libraries API:
http://pipwerks.com/journal/2008/11/11/swfobjectjs-finds-a-home-on-google-servers/
How & Why You Should Use Google CDN:
http://webmuch.com/how-why-you-should-use-google-cdn/
Of course, in the end, everyone's free to do whatever they want, myself included.
Oct. 23, 2009Edward Spiegel
Zachary,
The code you provided works. Can you explain to me why that code works in this case and that declaring playerReady the "standard" way doesn't.
I.e. if I have
function playerReady(obj){
//my code here
}
My playerReady works fine BUT the playlist doesn't get instantiated in the html page. If I use the method you provided in this thread, it works perfectly.
It might be worthwhile adding this style of implementing playerReady into the flash API wiki (where it shows the "standard" way)
p.s. Sorry if I am showing how unsophisticated my programming skills are.
Oct. 23, 2009Edward Spiegel
Hobbs,
I think the reason that people are having difficulty is that all of the examples on the site and even the current download -- use swfobject 1.5
Most of us are so busy that we build off the code that we see in the tutorials here and that comes with the software. It is pretty time-efficient. It looks like swfobject 2.x may well be the way to go -- but like a lot of people, I have already implemented a good chunk of code that will have to be re-done to switch to 2.x.
Are there examples on this site (other than here in the forum) that use swfobject 2.x?
Oct. 23, 2009Zachary Ozer
Hey Edward,
The code above simply reassigns an exiting function named "playerReady" to a new name, "myReady". It then executes whatever code you've written, and finally, executes the original playerReady.
Oct. 23, 2009hobbs
@Edward,
I have a small problem with this statement.
"I think the reason that people are having difficulty is that all of the examples on the site and even the current download -- use swfobject 1.5"
I have posted and made available through links to my Test Pages, literally thousands of examples, of code using swfobject v2.x. And many hundreds of users — maybe thousands, I don't have any way to know the full count — are quite successfully using swfobject v2.x.
Just so there's no confusion, I always put the JW player version and the swfobject version in the title of the HTML document, like this:
<title>Simple Flow - JWMP v4.6.x - swfobject v2.2</title>
As far as the conversion to new code, it's no worse than converting from the v2 player to the v3 player to the v4 player to the v5 player, where each time there have been substantial changes in the flashvars, API, and functionality of the player. That's just how things are in software development — plan on change as the norm.
I can change SWFObject v1.5 code to swfobject v2.2 code in less that 5 minutes, not that much of a burden, especailly compared to changing to the new APIs.
As a final note, if you go to the old SWFObject site, you will see a note from the developers stating that they consider SWFObject to be obsolete and no longer support it.
Oct. 23, 2009Edward Spiegel
Zachary,
Thanks for the explanation.
Hobbs,
I don't want to get into an argument. But you are misunderstanding me. The jwplayer download still includes swfobject 1.5 and the most of the pages on longtailvideo use version 1.5.
What I am telling you is that a lot of people are like me. They are only or primarily using swfobject to instantiate the jw player and so they are learning and using from the code that is provided with it and used on the tutorial pages here on this site.
There may well be examples here that use version 2.x
But all of the basic ones that I have visited and the download with the player and usage hints are using 1.5.
I am not saying that there are not examples of 2.2 being used out in the world or that you are wrong about 2.2 being preferable. I was talking about the examples published on longtailvideo
Btw, you talk about the thousands of examples on your site. What is the URL of your site?
Oct. 23, 2009hobbs
I wasn't trying to start an argument.
I'm just saying that there are many swfobject v2.2 examples posted on the Forum, which is considered to be a very important part of the documentation, as stated in the sidebar and several other places on the LTV site.
Here are a few of my Test Pages that are active:
http://willswonders.myip.org:8074/Simple_Flow.html
http://willswonders.myip.org:8074/Simple_RTMP.html
http://willswonders.myip.org:8074/Simple_Shoutcast-10.html
http://willswonders.myip.org:8074/Simple_Shoutcast_v3.html
http://willswonders.myip.org:8074/Simple_SingleFile.html
http://willswonders.myip.org:8074/Simple_SingleFile_v5.html
http://willswonders.myip.org:8074/Simple_Snapshot.html
http://willswonders.myip.org:8074/Simple_Viral-2.html
Bear in mind that they are Test Pages that may not always have full functionality or may have weird functionality, depending on what I'm testing.
I'm currently preparing to move many of my Test Pages to the LTV contributor's Wiki, so they will be readily available to all users, like andersen's are already available here http://developer.longtailvideo.com/contributors/nyboe
Not all 4,563 pages, because many of them were for a particular user and won't be useful in a generic sense, like this http://willswonders.myip.org:8074/rampantroostermorris.html which is just straightening out somebody's code from this thread http://www.longtailvideo.com/support/forum/Bug-Reports/20273/Youtube-video-not-working#msg135207
Generally, when a user requests a particular functionality, I activate a Test Page and direct them to that, as you can see in this thread http://www.longtailvideo.com/support/forum/Setup-Problems/20210/How-to-stream-multiple-radios-from-shoutcast-
The best thing to do, if you are looking for a particular functionality, is to ask for it. I probably have a working, tested page — or I can tell you how to do it — or not do it, if it's not possible.
I also have lots of PHP and other serverside code, such as this thread http://www.longtailvideo.com/support/forum/Plugins/17366/Powerpoint-Slide-Sync-Plugin
I'm sharing 40-years of programming experience; I can show you how to hack punch cards with a shaped nail if you ever need to know how to do that...
Oct. 24, 2009Edward Spiegel
Thanks Hobbs.
Oct. 24, 2009hobbs
You're more than welcome.
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.