From 9bd0d45731e8b772eaf775235d66f003dab3b18e Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Mon, 20 Jun 2011 13:24:44 -0400
Subject: [PATCH] Issue #1194312: Add a mini display formatter with a simple
 play/pause button.

---
 includes/jplayer.theme.inc |   19 +++++++++++++++++++
 jplayer.module             |   15 +++++++++++++++
 theme/jplayer.css          |   15 +++++++++++++++
 theme/jplayer.mini.tpl.php |   23 +++++++++++++++++++++++
 4 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 theme/jplayer.mini.tpl.php

diff --git a/includes/jplayer.theme.inc b/includes/jplayer.theme.inc
index 3cf8f15..9604524 100644
--- a/includes/jplayer.theme.inc
+++ b/includes/jplayer.theme.inc
@@ -29,6 +29,25 @@ function template_preprocess_jplayer_single(&$vars) {
 }
 
 /**
+ * Theme a single file in a mini player with only the play/pause button.
+ */
+function theme_jplayer_formatter_mini($element) {
+  if ($element['#item']['fid']) {
+    jplayer_add();
+    return theme('jplayer_mini', $element);
+  }
+  return '';
+}
+
+/**
+ * Preprocess function for the mini player.
+ */
+function template_preprocess_jplayer_mini(&$vars) {
+  template_preprocess_jplayer_single($vars);
+  $vars['mode'] = 'mini';
+}
+
+/**
  * Themes multiple items as playlist.
  */
 function theme_jplayer_formatter_playlist($element) {
diff --git a/jplayer.module b/jplayer.module
index c8e5bcf..13a00ed 100644
--- a/jplayer.module
+++ b/jplayer.module
@@ -40,6 +40,15 @@ function jplayer_theme() {
       'template' => 'theme/jplayer',
       'file' => 'includes/jplayer.theme.inc',
     ),
+    'jplayer_formatter_mini' => array(
+      'arguments' => array('element' => NULL),
+      'file' => 'includes/jplayer.theme.inc',
+    ),
+    'jplayer_mini' => array(
+      'arguments' => array('element' => NULL),
+      'template' => 'theme/jplayer.mini',
+      'file' => 'includes/jplayer.theme.inc',
+    ),
     'jplayer_formatter_playlist' => array(
       'arguments' => array('element' => NULL),
       'file' => 'includes/jplayer.theme.inc',
@@ -78,6 +87,12 @@ function jplayer_field_formatter_info() {
       'multiple values' => CONTENT_HANDLE_CORE,
       'description' => t('Display an audio file as an HTML5-compatible with Flash-fallback audio player.'),
     ),
+    'mini' => array(
+      'label' => t('jPlayer miniplayer'),
+      'field types' => array('filefield', 'audiofield'),
+      'multiple values' => CONTENT_HANDLE_CORE,
+      'description' => t('Display an audio file as an HTML5-compatible with Flash-fallback audio player.'),
+    ),
     'playlist' => array(
       'label' => t('jPlayer multifile playlist'),
       'field types' => array('filefield', 'audiofield'),
diff --git a/theme/jplayer.css b/theme/jplayer.css
index bbe8e11..37c888a 100644
--- a/theme/jplayer.css
+++ b/theme/jplayer.css
@@ -41,6 +41,12 @@ div.jp-interface ul.jp-controls a {
   overflow: hidden;
   text-indent: -9999px;
 }
+div.jp-mini-player div.jp-interface {
+  background: none;
+  border: none;
+  width: 50px;
+  height: 50px;
+}
 a.jp-play,
 a.jp-pause {
   top: 20px;
@@ -55,6 +61,11 @@ div.jp-playlist-player a.jp-play,
 div.jp-playlist-player a.jp-pause {
   left: 48px;
 }
+div.jp-mini-player div.jp-interface ul.jp-controls a.jp-play,
+div.jp-mini-player div.jp-interface ul.jp-controls a.jp-pause {
+  top: 0;
+  left: 0;
+}
 a.jp-play {
   background: url(jplayer.jpg) 0 0 no-repeat;
 }
@@ -193,6 +204,10 @@ div.jp-single-player div.jp-play-time,
 div.jp-single-player div.jp-total-time {
   left: 130px;
 }
+div.jp-mini-player div.jp-play-time,
+div.jp-mini-player div.jp-total-time {
+  display: none;
+}
 div.jp-playlist-player div.jp-play-time,
 div.jp-playlist-player div.jp-total-time {
   left: 164px;
diff --git a/theme/jplayer.mini.tpl.php b/theme/jplayer.mini.tpl.php
new file mode 100644
index 0000000..8deb46f
--- /dev/null
+++ b/theme/jplayer.mini.tpl.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * Provide the HTML output of the jPlayer audio player.
+ */
+?>
+
+<div id="<?php print $player_id; ?>" class="jplayer" rel="<?php print $item['url']; ?>"></div>
+
+<div class="jp-<?php print $mode; ?>-player">
+  <div class="jp-interface">
+    <ul class="jp-controls">
+      <li><a href="#" id="<?php print $player_id; ?>-play" class="jp-play" title="<?php print t('play'); ?>"><?php print t('play'); ?></a></li>
+      <li><a href="#" id="<?php print $player_id; ?>-pause" class="jp-pause" title="<?php print t('pause'); ?>"><?php print t('pause'); ?></a></li>
+
+
+    </ul>
+
+    <div id="<?php print $player_id; ?>-play-time" class="jp-play-time"></div>
+    <div id="<?php print $player_id; ?>-total-time" class="jp-total-time"></div>
+  </div>
+
+</div>
-- 
1.7.5.4

