This patch add an input filter for text formats that allows it to process jwplayer shortcode. This utilizes a similar method to the drupal 6 jwplayermodule method of finding shortcodes in body content but applies it at the input filter level so you can use it on any text field. Apply the patch, click the checkbox for an input filter and then you can copy and paste jwplayer formed shortcodes into textareas and have them render as the player.

I've posted a video showing what this patch gives you as well as an overview of how to use it: http://www.youtube.com/watch?v=nyktBwxGryQ

Hope this makes its way into the module as it's a nice complement to the existing field formatter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rickvug’s picture

I'm really on the fence about bundling short code functionality into JW Player module. Something that I don't like about some of the modules in the video space (I'm not naming names!) is their attempts to try to do everything. Up until now I've tried to restrict JW Player to formatting, with only integration into key APIs such as Field API. The idea is that I'd like to have JW Player fit into an ecosystem of general video modules, allowing the developer to easily sub out their video player if needed.

For my own use of shortcodes I've relied on the Media module. The Media module uses field formatters to render files inserted via a WYSIWYG editor. At a conceptual level I much prefer this generic approach in place of building a one-off shortcode system into the module itself. The problem with this is that the configuration is not obvious to an initial Drupal user.

It would be good to hear the opinions of others on this topic.

btopro’s picture

That makes sense but since it's in the D6 version (which we currently use) I'll split it off to it's own thing as a separate project since this is a requirement of how we do business.

rickvug’s picture

It would be good to have an overview of similar modules in this space. There must be another module besides Media that allows for rendered entities to be inserted into text areas. A format such as [entity_type|entity_id|view_mode] would contain all of the information needed. To render a file entity with JW Player set as the file formatter in the Large view mode would become [file|123|large].

btopro’s picture

I don't use this for rending entities, while I understand that makes sense for most people I'm actually using it to render jwplayer short-code markup that's being generated by another site. We have an asset management system that generates the jwplayer shortcodes and then we embed them in our content from that system. The more I describe it the more it sounds tangentially related to the goals of this project.

julianmancera’s picture

Hi

Can you please post a full example of the usage?

Thank you

Julian Mancera

btopro’s picture

kingfisher64’s picture

Patch applies cleanly against 26th Jan 2013 dev version.

Hunk #1 succeeded at 507 (offset 28 lines).

Shortcode greatly enhances the usability of drupal in multiple ways, not least those hopefully making the transition from wordpress to drupal (not me)!

http://drupal.org/project/shortcode
http://drupal.org/project/sc_basic

Good stuff thank you.

HLopes’s picture

Doesn't do anything here.

Patched against 7.x-1.0-alpha1, enabled the input filter, re-saved the node & cleared cache.

Shortcode:

[jwplayer config="some_config_name" image="http://img.youtube.com/vi/NFR-ADakI-c/hqdefault.jpg" file="http://www.youtube.com/watch?v=NFR-ADakI-c" skin="http://www.some_domain_name.com/wp-content/plugins/jw-player-plugin-for-..."]

Result:

[jwplayer config="some_config_name" image="http://img.youtube.com/vi/NFR-ADakI-c/hqdefault.jpg" file="http://www.youtube.com/watch?v=NFR-ADakI-c" skin="http://www.some_domain_name.com/wp-content/plugins/jw-player-plugin-for-..."]

No errors (js or php).

ron_s’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes
Related issues: +#2713725: Refactor theming
FileSize
4.96 KB

Attached is a new patch that takes into consideration the refactor theming patch: https://www.drupal.org/node/2713725

Refactor theming removes all inline javascript and replaces it with #attached and Drupal.behaviors.

Please test using 7.x-2.x-dev and the patch in #2713725.

The patch seems to work well, except we are noticing some situations where videos do not display until all caches have been flushed. Once they are flushed, the videos display properly.

If anyone has recommendations on how to resolve this, it would be appreciated. Thanks.

ron_s’s picture

@Berdir, given that you don't like include files, modified this patch to add the changes to jw_player.module. See attached.

Berdir’s picture

Status: Needs review » Needs work

Interesting feature, but could use a bit more documentation on how to define it, the description doesn't really explain how to specify those options.

For the caching problem, I think you will have to declare the filter as uncacheable. That's usually needed for something dynamic as this that needsto add something to the page.

That also means that enabling this is a performance hit and the documentation should include a recommendation to use a separate text format for this that is only used when you actually need an embedded player. Otherwise you might end up disabling caching on hundreds of texts just because you have one or two nodes with an embedded player.

As an alternative, I'd suggest to look at Paragraphs: https://www.drupal.org/project/paragraphs. With that, you could define a video paragraph type, with a file and/or link field that is displayed as a jw player.

ron_s’s picture

Status: Needs work » Needs review
FileSize
13.76 KB
9.82 KB

Included is much more documentation and took care of the caching issue. Also decided to create it as a separate module, since I'm sure there are some people not interested in such a feature.

Regarding the Paragraphs module, I'm very familiar with it. Might be willing to create something in support of it in the future depending on the direction the module takes.

I certainly understand what Paragraphs is trying to do, and I'm sure it works very well for more technically-inclined content creators. However our experience has shown it is too involved for average contributors who just want to post content as quickly as possible and move on to the next task.

There eventually needs to be a true WYSIWYG / drag-and-drop interface for content building, and maybe Paragraphs is a step in that direction, but not quite there as of yet for average users.

kpv’s picture

To insert a jwplayer video into wysiwyg you can reuse a generic Media module html5 widget and then just replace it with jwplayer when rendered on client side
i.e.

$("video").each(function(index){
  var src = $(this).find("source").first().attr("src");
  var jw_replacement_id = 'jw-video-replacement-'+index;
  $(this).replaceWith('<div id="'+jw_replacement_id+'"></div>');
  jwplayer(jw_replacement_id).setup({
    "file": src,
    "height": 360,
    "width": 640,
  });
});

and

function mymodule_init() {
  libraries_load('jwplayer');
}