Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey guys
I am trying to use Jplayer with link fields. I want people to be able to link to audio files outside of my own website for audio previews however jplayer always defaults the base of the link back to the base of my files folder, I get the link but drupal thinks its a file in my files folder.
eg.
/files/http://www.archive.org/download/Various-NetlabelCoalitionVolume1/02.DrSj...
Is there anyway around this?
Comment | File | Size | Author |
---|---|---|---|
#13 | 0001-adding-support-for-textfield-and-link-field 1.patch | 3.74 KB | pwaterz |
#11 | 0001-Adding-support-for-textfield-and-link-field.patch | 3.81 KB | pwaterz |
#3 | 903918-3.jplayer-emaudio.patch | 6.39 KB | dww |
Comments
Comment #1
jimajamma CreditAttribution: jimajamma commentedI've been looking at doing this, it's both trivial and nontrivial wrapped up in one, but I should have something in the next week or so. In the meantime, you might want to take a look at the emfield module (drupal.org/project/emfield) that embeds all kinds of external media files.
Jim
Comment #2
dwwYeah, but it'd be nice to be able to use jPlayer with an emfield. I'm definitely interested in this, although I haven't started looking into the code yet (and probably won't have time in the near future).
Comment #3
dwwThis works fine for me with an emaudio field. I haven't tried with a regular filefield, but I'm pretty sure I didn't break anything. ;) I'm not much of a CCK hacker yet, so it's possible there are better/cleaner ways to do this. For example, inside jplayer_get_source_url() it didn't seem like it was possible to get the underlying field type of the element (e.g. filefield vs. emaudio) so it's a bit of a heuristic hack to find the right URL. Also, I'm not 100% sure of the security implications of using the raw URL from emaudio like this, I'd want to ponder that a bit more before I really advocated this should be committed. But, it's a start. I'd love to get feedback on this approach from the maintainers.
Thanks!
-Derek
Comment #4
jimajamma CreditAttribution: jimajamma commentedI'm even more of a newb, but was looking at adding different handlers per field type to the jplayer_field_formatter_info() array, eg, setting 'field_types' to emaudio only and then calling a specific function for that, another for links, etc. But certainly checking things out internally the way you did it works great, too.
Comment #5
dwwYeah, it seemed like it'd be a lot of duplicate code (and potentially more confusing UI) to have separate formatters. I thought it'd be better to just have a single formatter that was smart enough to figure out where your audio file lives, since 95% of the code is the same in all cases. But, I also assumed that the formatter would get more metadata about the field its formatting so it'd be cleaner and easier to figure out the right URL based on the field type. Maybe it does, and I just didn't see it in my various debugging explorations...
Comment #6
plachThe patch works flawlessly: I test it in "mixed mode" having an embedded audio and a file field in the same content type and everything behaved as expected. If we don't want to go on with design considerations I'd say this is good to go.
Comment #7
ju.ri CreditAttribution: ju.ri commentedI have the same problem after trying to move audiofiles to Amazon S3, using the media mover module. After applying the above patch I still get wrong URLs.
Comment #8
andrewfn CreditAttribution: andrewfn commentedThis looks like a very valuable feature. The code looks good on an initial review but I will go through it again more carefully and do some testing.
Comment #9
deviantintegral CreditAttribution: deviantintegral commentedUnfortunately this patch no longer applies to 6.x-1.x. Lets see about porting this to the D7 version and getting them both committed.
Comment #10
dwwSadly, I have no time to re-write this now -- unassigning myself so no one gets the mistaken impression I'm working on this. ;)
That said, I'm still using this patch on a site I maintain, so I'm still keenly interested in seeing this make it in upstream. At some point I'll circle back to needing to spend more time with that site, and perhaps at that point I'll be able to port this. Meanwhile, if anyone else can get it done sooner, hurray for that.
Cheers,
-Derek
Comment #11
pwaterz CreditAttribution: pwaterz commentedHere is the patch for drupal 7 jplayer. This patch adds support for use of a textfield or a link field.
Comment #12
deviantintegral CreditAttribution: deviantintegral commentedExtra change not needed.
Fix comment style.
No-op change.
"fiele_type" should be "file_type". Perhaps a better name would be item type, since a url is not a file by definition? Also, good opportunity to add phpdoc @param and @return comments to this function.
Why is this required, this assignment doesn't change the variable?
Comment #13
pwaterz CreditAttribution: pwaterz commentedHere is a new patch. It may not be super perfect, but pretty close.
Comment #14
pwaterz CreditAttribution: pwaterz commentedComment #15
pwaterz CreditAttribution: pwaterz commented