? mediaelement Index: README.txt =================================================================== RCS file: README.txt diff -N README.txt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ README.txt 27 Aug 2010 17:20:20 -0000 @@ -0,0 +1,18 @@ +$Id$ +Media Element +-------------------------------------------------------------------------------- + +Provides HTML5 video and audio elements using Mediaelement.js for HTML4 browsers. + +Installation +-------------------------------------------------------------------------------- + +1. Download Media Element from http://mediaelementjs.com/ +2. Unzip into the module directory + +Usage +-------------------------------------------------------------------------------- + +Set a file field to use video (or audio) as its display formatter. +Or use the media module (http://drupal.org/project/media) if you want to have your +file field display images and video. \ No newline at end of file Index: mediaelement.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mediaelement/mediaelement.admin.inc,v retrieving revision 1.1 diff -u -r1.1 mediaelement.admin.inc --- mediaelement.admin.inc 29 Jul 2010 22:46:41 -0000 1.1 +++ mediaelement.admin.inc 27 Aug 2010 17:20:20 -0000 @@ -9,7 +9,7 @@ // Detect if the library is available. If it is not available display a // message. - $libraries = libraries_get_libraries(); + $path = drupal_get_path('library', 'mediaelement'); if (!isset($libraries['mediaelement'])) { $form['message'] = array( '#value' => '

'. t('The MediaElement.js library is not installed. Please download the library from MediaElementjs.com and place it in your libraries folder.', array('!url' => 'http://mediaelementjs.com')) .'

', @@ -21,8 +21,7 @@ '#title' => t('Enable MediaElement.js site wide'), '#default_value' => variable_get('mediaelement_sitewide', FALSE), ); - - $path = libraries_get_path('mediaelement'); + $form['test'] = array( '#value' => '', ); Index: mediaelement.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mediaelement/mediaelement.info,v retrieving revision 1.1 diff -u -r1.1 mediaelement.info --- mediaelement.info 29 Jul 2010 22:46:41 -0000 1.1 +++ mediaelement.info 27 Aug 2010 17:20:20 -0000 @@ -1,6 +1,5 @@ ; $Id: mediaelement.info,v 1.1 2010/07/29 22:46:41 mfer Exp $ name = "MediaElement.js" description = "Provide MediaElement.js to be used on the entire site or just with Filefields." -dependencies[] = libraries -core = 6.x +core = 7.x php = 5.2 \ No newline at end of file Index: mediaelement.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mediaelement/mediaelement.js,v retrieving revision 1.1 diff -u -r1.1 mediaelement.js --- mediaelement.js 29 Jul 2010 22:46:41 -0000 1.1 +++ mediaelement.js 27 Aug 2010 17:20:20 -0000 @@ -1,6 +1,6 @@ // $Id: mediaelement.js,v 1.1 2010/07/29 22:46:41 mfer Exp $ ;(function($, undefined){ - + alert('fuck'); /** * When set to enable mediaelement for all audi/video files add it to the page. */ Index: mediaelement.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mediaelement/mediaelement.module,v retrieving revision 1.1 diff -u -r1.1 mediaelement.module --- mediaelement.module 29 Jul 2010 22:46:41 -0000 1.1 +++ mediaelement.module 27 Aug 2010 17:20:20 -0000 @@ -3,7 +3,7 @@ /** * @file - * Provide support for MediaElement.js to the entire site of just Filefield. + * Provides HTML5 video and audio elements using Mediaelement.js for HTML4 browsers. */ /** @@ -30,16 +30,120 @@ } /** + * Implementation of hook_library(). + */ +function mediaelement_library() { + $path = drupal_get_path('module', 'mediaelement'); + $libraries = array(); + + $libraries['mediaelement'] = array( + 'title' => 'Media Element', + 'website' => 'http://mediaelementjs.com/', + 'version' => '7.x', + 'js' => array( + $path . '/mediaelement/src/mediaelement.js' => array('weight' => JS_LIBRARY - 5), + $path .'/mediaelement.js', + array('type' => 'setting', 'data' => array('mediaelement' => array(array('all' => TRUE)))), + ), + 'css' => array( + $path . '/mediaelement/src/mediaelementplayer.css' + ), + ); + return $libraries; +} + +/** * Implementation of hook_init(). */ function mediaelement_init() { // When the media player is set to be on all pages add it to the page. if (variable_get('mediaelement_sitewide', FALSE)) { - $path = libraries_get_path('mediaelement'); - drupal_add_js($path .'/src/mediaelement.js'); - drupal_add_js($path .'/src/mediaelementplayer.js'); - drupal_add_js(array('mediaelement' => array('all' => TRUE)), 'setting'); - drupal_add_js(drupal_get_path('module', 'mediaelement') .'/mediaelement.js'); - drupal_add_css($path .'/src/mediaelementplayer.css'); + drupal_add_library('mediaelement', 'mediaelement'); + } +} + + +/** + * Implements hook_field_formatter_info(). + * Not sure this belongs here, it is really just for embedding HTML5 audio/video + */ +function mediaelement_field_formatter_info() { + $formatters = array(); + + $formatters['video'] = array( + 'label' => t('Video'), + 'field types' => array('file'), + ); + + $formatters['audio'] = array( + 'label' => t('Audio'), + 'field types' => array('file'), + ); + + return $formatters; +} + +/** + * Implements hook_field_formatter_view(). + */ +function mediaelement_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { + $element = array(); + + foreach ($items as $delta => $item) { + $element[$delta] = array( + '#theme' => 'video_formatter', + '#item' => $item, + '#path' => isset($uri) ? $uri : '', + ); } + return $element; +} + +/** + * Implements hook_theme(). + */ +function mediaelement_theme() { + return array( + 'video_formatter' => array( + 'variables' => array('item' => NULL), + ), + 'audio_formatter' => array( + 'variables' => array('item' => NULL), + ), + 'video' => array( + 'variables' => array('src' => NULL, 'controls' => TRUE), + ), + 'audio' => array( + 'variables' => array('src' => NULL, 'controls' => TRUE), + ), + ); +} + +function theme_video_formatter($variables) { + $item = $variables['item']; + $properties = array( + 'src' => file_create_url($item['uri']), + ); + return theme('video', $properties); + +} + +function theme_audio_formatter($variables) { + $item = $variables['item']; + $properties = array( + 'src' => file_create_url($item['uri']), + ); + return theme('audio', $properties); +} + +function theme_video($variables) { + $src = $variables['src']; + $controls = $variables['controls']; + return '