Hey All,

First off, let me STRESS that I am a big big newb here, akin to a monkey with a stick, banging at code until it works, but when I started looking at using jPlayer with views this morning, I noticed some odd behavior.

I created a quick and dirty view, the usual filtering on published and node type, putting in an mp3 field (as generic files), selecting jPlayer as the style, and sure enough, a playlist box showed up in live preview.

But...no dice, looked pretty, didn't work. Instead of yada/yada/yada.mp3, it was href'ing MYHOST/sites/default/files/##.

I dug into jplayer_style_plugin.inc and banged at it with that aforementioned stick for a while and found that it was putting a plain old fid into $filepath, which file_create_url() was then turning into MYHOST/sites/default/file/##, so I googled and grep'ed around trying to figure out how it lost the filename in the first place--couldn't figure that part out--so then how to get a filename from a fid in drupal and came up with this:

$jf = field_file_load($filepath);

and then using that when the url is created a couple lines later:

'url' => file_create_url($jf[filepath]),

And, voila, all works. My description shows up in the player and the mp3 file is played. I can change my field display format from Generic Files to Path to File or URL to file, and they work, too, just a bit uglier in presentation in my humble opinion.

Now.... while this does appear to have the added benefit of priming drupal's cache with your yet to be played mp3 files, I can't imagine this is the right way to do this. Or that something on my system fat fingered something else that caused this oddity in the first place...

Thoughts?

Jim

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heshanlk’s picture

Status: Active » Needs review
FileSize
1.36 KB

Hope this worked to fix that. I got the same issue when I create views and managed to fix using this patch.

davebv’s picture

Thanks @heshan.lk. The patch is working great.

jimajamma’s picture

D'oh! I forgot to reply to my own question. I did similar but used field_file_load() instead of doing the db_query directly.

Jim

design.er’s picture

This patch works great. Thank you so much for fixing this bug! :)

stevetweeddale’s picture

Views integration was broken for me too - I used jimjamma's field_file_load approach. There was also a couple of lines at the top of the template_preprocess_jplayer_view_playlist that looked like they were be breaking things.

Anyway, as I was changing things a fair bit in the style plugin I included these fixes in a patch over at #981982: How to display other links/fields along with the actual mp3 link?.

deviantintegral’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Status: Needs review » Postponed

Here's a rerolled patch that also fixes a few style issues. I can't test this due to the issues I'm running into over at #961058: Jplayer not working with views for me, so I'm marking this as postponed.

deviantintegral’s picture

Status: Postponed » Fixed
FileSize
2.61 KB

Turns out this was a pretty simple fix to get the Views style working again. I've committed a rebased version of this patch (that I missed uploading in #7).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.