Great module... thanks! I like the style "pluggability" and the other progress others made with exclusions and other transformations.

My use-case for JW Player would also apply to any other video players that have a JS API and/or XML Namespace I believe. This project uses a licensed JW Player so it didnt have a budget for using true mRSS specification. Exclude wont fit this use case since some fields come from file_entity. True mRSS, particularly for the "media:content", is either a quoted array inside the tag or single quoted values within each tag.

<media:content
  url="http://www.foo.com/movie.mp4"
  thumbnail="http://www.foo.com/movie-move.jpg"
  fileSize="12216320"
  type="video/quicktime"
  medium="video"
  isDefault="true"
  expression="full"
  bitrate="128"
  framerate="25"
  samplingrate="44.1"
  channels="2"
  duration="185"
  height="200"
  width="300"
  lang="en" />
or
<media:content url="http://www.foo.com/movie.mp4" />
<media:thumbnail url="http://www.foo.com/movie-move.jpg" />

So to do real mRSS obviously poses trouble but wondered if anyone has worked on adding that as a style to this module?

I hijacked the XML style and only modifed the header, body and footer templates and added a few lines of code to eliminate drupal-inserted multiple line breaks, spaces and space/line-break combinations to get it to render on one line. Even with strip html and remove whitespace on a field a whole bunch of garbage is output with fields that come from "file_entity -> Video File -> Fields assigned to that style

views-data-export-xml-header.tpl.php

<?php
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $rows: An array of row items. Each row is an array of content
 *   keyed by field ID.
 * - $header: an array of headers(labels) for fields.
 * - $themed_rows: a array of rows with themed fields.
 * @ingroup views_templates
 */

// Short tags act bad below in the html so we print it here.
//print '<?xml version="1.0" encoding="UTF-8"
/*<<?php print $root_node; ?>> ?>';*/
print '<rss xmlns:jwplayer="http://developer.longtailvideo.com/trac/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">';
?>
<?php print '
  <channel>';?>
<?php print '
    <title>JW Player Video Playlist</title>'
;?>

views-data-export-xml-body.tpl.php

<?php
/**
 * @file views-view-table.tpl.php
 * Template to display a view as a table.
 *
 * - $title : The title of this group of rows.  May be empty.
 * - $rows: An array of row items. Each row is an array of content
 *   keyed by field ID.
 * - $header: an array of headers(labels) for fields.
 * - $themed_rows: a array of rows with themed fields.
 * @ingroup views_templates
 
   DRIVE: $item_item defined here as workaround from default "$item_node"
          item could be hardcoded, this only replicates orig template structure
 */
	$item_item = 'item';
?>

<?php foreach ($themed_rows as $count => $row): ?>
     <<?php print $item_item; ?>>
<?php foreach ($row as $field => $content): ?>
      <<?php print $xml_tag[$field]; ?>><?php print $content; ?></<?php print $xml_tag[$field]; ?>>
<?php endforeach; ?>
     </<?php print $item_item; ?>>
<?php endforeach; ?>

views-data-export-xml-footer.tpl.php

<?php //print $root_node; ?>
<?php print '  </channel>';?>
<?php print '
</rss>';?>

views_data_export.theme.inc

/**
 * Preprocess xml output template.
 */
function template_preprocess_views_data_export_xml_body(&$vars) {
  _views_data_export_header_shared_preprocess($vars);
  _views_data_export_body_shared_preprocess($vars);

  // Compute the tag name based on the views base table, minus any trailing 's'.
  $vars['item_node'] = _views_data_export_xml_tag_clean(rtrim($vars['view']->base_table, 's'));

  foreach ($vars['themed_rows'] as $num => $row) {
    foreach ($row as $field => $content) {
      // Prevent double encoding of the ampersand. Look for the entities produced by check_plain().
      $content = preg_replace('/&(?!(amp|quot|#039|lt|gt);)/', '&amp;', $content);
      // Convert < and > to HTML entities.
      $content = str_replace(
        array('<', '>'),
        array('&lt;', '&gt;'),
        $content);
        //
        // DRIVE - ADDED LINE TO REMOVE LINE RETURNS AND SPACES FROM DRUPAL OUTPUT
        //
        $content = preg_replace(array('/\\\\n/'), '', $content);
        $content = preg_replace(array('/\\n/'), '', $content);
        $content = preg_replace(array('/\\s\s/'), '', $content);
        $content = preg_replace('/\/ /', '/', $content);
      $vars['themed_rows'][$num][$field] = $content;
    }
  }

I added a Node template according to my view and put it in mytheme/templates/node--video_article.tpl.php which is the proper naming convention for my content-type which is "video_article". I attached that template as well. It has two sections which outputs a simple one-video player in teasers (default JW skin) and the full player with playlist in node view with a custom skin.

I know we should use GIT and so forth but time constraints limit to this example of using JW Player playlist mixing with mRSS (only 'description' field but mixed nevertheless).

Small adaptations to this example would work for other players like MediaFront I believe.

*It is very hard to find info on xml playlist generation. PPL who know how don't often share so this example aims at using Views Data Export to create playlists, particularly on nodes, that can also be shared across domains by using a cross-domain XML file.
**If using MP4's see H.264 codec if you have streaming trouble
***Relevance: desire to see true mRSS Style in this module down the road :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DRIVE’s picture

My mytheme/templates/node--article_video.tpl.php template:

<article<?php print $attributes; ?>>
  <?php print render($title_prefix); ?>
  <?php if (!$page && $title): ?>
  <header>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
  </header>
  <?php endif; ?>
  <?php print render($title_suffix); ?>
  <?php if ($display_submitted): ?>
  <footer class="submitted">
  <?php print $user_picture; ?>
  <div class="submitteduser"><?php print $date; ?> -- <?php print $name; ?>.</div></footer>
  <?php endif; ?>  

  <?php if ($teaser): ?>
  <div<?php print $content_attributes; ?>>
    <!-- teaser template HTML here -->
<script type="text/javascript" src="/sites/all/libraries/jwplayer/jwplayer.js"></script>
<div style="float:left;margin-top:0px;margin-right:18px;margin-bottom:10px;margin-left:0px;width:280px;margin-right:10px;padding:3px;background:#242424;border-radius:4px;text-align:left;">
<div id="mediaplayer<?php print $nid ?>" style="color:#FFFFFF;padding-right:10px;">  LOADING VIDEO PLAYER...</div>
    <script type="text/javascript">
    jwplayer("mediaplayer<?php print $nid ?>").setup({
      'flashplayer': '/sites/all/libraries/jwplayer/player.swf',
        'allownetworking': 'all',
        'allowscriptaccess': 'always',
        'id': 'playerID',
        'volume': '59',
        'controlbar': 'bottom',
        'controlbar.backgroundcolor': '0x5F5F60',
        'width': '280',
        'height': '182',
        'backcolor': '0x000000',
        'frontcolor': '0xC0C0C0',
        'lightcolor': '0xCCFF33',
        'screencolor': '0x000000',
        'logo.file': '/sites/all/libraries/jwplayer/jw-player-licensed-logo-bitmap.png',
        'logo.hide': 'false',
								'stretching': 'fill',
        'wmode': 'transparent',
        'playlistfile': '/playlists/<?php print $nid ?>/playlist.xml'
});
</script>
</div>
  <?php else: ?>
  <div<?php print $content_attributes; ?>>
    <!-- regular node view template HTML here --> 
<script type="text/javascript" src="/sites/all/libraries/jwplayer/jwplayer.js"></script>
<div align="center" style="max-width:720px;margin:0 auto;padding:3px;background:#1B1B1B;border:1px solid #020202;border-radius:4px;text-align:left;">
 <div id="mediaplayer">  LOADING VIDEO PLAYER...</div>
    <script type="text/javascript">
    jwplayer("mediaplayer").setup({
        'flashplayer': "/sites/all/libraries/jwplayer/player.swf",
        'allownetworking': 'all',
        'allowscriptaccess': 'always',
        'id': 'playerID',
        'volume': '59',
        'controlbar': 'bottom',
        'controlbar.backgroundcolor': '0x969696',
        'width': '100%',
        'height': '520',
        'backcolor': '0x000000',
        'frontcolor': '0xffffff',
        'lightcolor': '0x555555',
        'screencolor': '0x1B1B1B',
        'logo.file': '/sites/all/libraries/jwplayer/jw-player-licensed-logo-bitmap.png',
        'logo.hide': 'false',
        'stretching': 'fill',
        'wmode': 'transparent',
        'playlist.position': 'bottom',
        'playlist.size': '139',
        'playlist.activecolor': '0xF1F1F1',
        'playlist.overcolor': '0x99FF00',
        'playlist.fontcolor': '0xA8A8A8',
        'repeat': 'list',
        'skin': '/sites/all/libraries/jwplayer/skins/customskin/customskin.zip',
     "plugins": {
          "viral-2": {
                    //"dock": "true",
                    "onpause": "false",
                    "callout": "none",
                    "allowmenu": "true",
                    "functions": "info",
                    "embed": "false",
                    "email_subject": "SOME EMAIL SUBJECT",
                    "email_footer": "EXAMPLE EMAIL FOOTER - EXAMPLE PRODUCTIONS "
                    },
          "fbit-1": {
                    "dock": "true",
          "fbit.link": "true"
                    },
          "tweetit-1": {
                    "dock": "true",
          "tweetit.link": "true"
                    },
"sharing-3": {
                    "dock": "true"
                    }
           },
        'playlistfile': '/playlists/<?php print $nid ?>/playlist.xml'
});
</script>
</div>
<?php endif; ?>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>



  <div class="clearfix">
    <?php if (!empty($content['links'])): ?>
      <nav class="links node-links clearfix"><?php print render($content['links']); ?></nav>
    <?php endif; ?>

    <?php print render($content['comments']); ?>
  </div>
</article>
DRIVE’s picture

NOTE: This template comes from a sub-theme of OMEGA using HTML5

kingandy’s picture

Thanks for these templates! It would be nifty to be able to manually set the $root_node (eg "channel") and $item_node (eg "item") within the views UI, but I guess that's a subtly different issue...

kingandy’s picture

Issue summary: View changes

Supplement: link to cross-domain xml file

decibel.places’s picture

Interesting approach. I read this, but I opted to create the playlist in RSS/XML and display the player in a block without any tpl files here is my blog post

DRIVE’s picture

@#4 -- thanks for the information - nice blog post but when I tried to view your working example I received page-not-found. Is there a link to your working example?

decibel.places’s picture

@ #5 the link is correct http://proudcampus.com/

we had some uptime issues caused by another dev misconfiguring the Ultimate Cron module

DRIVE’s picture

Very good.... looks nice. Lots of nice goodies in the site... .kudos

Steven Jones’s picture

Status: Active » Postponed
Issue tags: +new formats