jplayer script not working when nobody is logged in

Permalink 1 user found helpful
Hi

For some media files to work on my C5 website, I need these 2 javascript libraries to run:

<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>

<script type='text/javascript' src="http://www.jplayer.org/latest/js/jquery.jplayer.min.js"></script>


The first is jquery which I believe is already included in C5 by default.

The second is jplayer which I added in "Extra Header Content" of the page. It seems to be the most straight forward method. (I do not know much programming)

Then I discovered that my media files would not work half the time. It is very inconsistent. I am at my wits end doing testing. I am still not entirely clear why but I believe they fail when nobody is logged in or if the page is not in the edit mode.

Please can someone advise if they know what could be the problem and if my deduction is correct. If so, is there a better way to ensure my scripts run 100% of the time regardless of the mode the page is in?

many thanks!!

decleaf
 
JohntheFish replied on at Permalink Reply
JohntheFish
To find out more you can use the browser developer console. See the last section of:
http://www.concrete5.org/documentation/how-tos/editors/getting-help...

What you need to check for:
- that the libraries you need are actually being requested and loaded in both the login and not logged in cases (header section of elements tab of developer console, resources tab and network tab)
- that there are no script errors (console tab)

One other possibility, it could be c5 caching, so switch off and clear the cache in the c5 dashboard.
decleaf replied on at Permalink Reply
decleaf
Thanks for the tip. I used the Console and checked that the jplayer script did load in both instances (logged in and not).

I've cleared my cache as well.

Again, experienced the same inconsistencies.

I am going to try to test it again on another machine later and see how it goes.

Meanwhile, thanks again for the tip - it helped me to narrow down the problem at least.
JohntheFish replied on at Permalink Reply
JohntheFish
I think the Clevyr player addon may use jPlayer
http://www.concrete5.org/marketplace/addons/clevyr-player/...

There are also plenty of other media player addons (both paid and free) in the marketplace.
JohntheFish replied on at Permalink Reply
JohntheFish
With the developer console,you did not mention if it is showing any script errors for either the logged in user or anonymous user.
decleaf replied on at Permalink Reply
decleaf
The console showed only 1 error - that of the loading of a Disqus widget, which has nothing to do with the jplayer script problem.

I looked in the <head></head> section and saw that the jplayer script is here. I assume that means it's loading fine.

As for your suggestion of using an addon, I am not sure if it fits my requirements. I am actually creating a few buttons and images and making them play music when user clicks on them. The buttons and images need to be of a design of my choosing.

Thanks again for your kind help. I am still testing the codes.
JohntheFish replied on at Permalink Reply
JohntheFish
Some possibilities

- the script to initialise jPlayer is not being run.

- when initialised, jPlayer can't find the dom elements it is supposed to attach to.

To test the first, you can put a
console.log('hello');

into the script and check that 'hello' appears in the developer console, or even get it to spit out any initialisation data.

To test the second, you can chain some jQuery to mark the display:
$(selector).whatever_kicks_off_jPlayer().parent().css('background','pink);

If the initial selector is found, its parent gets a pink background.

There are some other script debugging tricks in
http://www.concrete5.org/documentation/how-tos/developers/some-tric...
decleaf replied on at Permalink Reply
decleaf
JohntheFish,

Thanks for your advise. I have some success with my troubleshooting. The problem lies with my code. (I'm a kluz!) The jplayer script driven event is working now whether I am logged on or not. First problem solved.

But now I have another problem. I discovered that on pages where I have this jplayer script running, the Superfish Dropdown Navigation menu (using superfish.js) stops working. While I can trigger the dropdowns, nothing happens when I click on the individual bars on the dropdown.

Does anyone have any idea why this is happening?

Many Thanks!