Example #1
0
 function display_entity()
 {
     $this->start_table();
     // Embedded preview
     $avd = new reasonAVDisplay();
     $avd->disable_automatic_play_start();
     if ($image_info = reason_get_media_placard_image_info($this->_entity)) {
         $avd->set_placard_image($image_info['url']);
         $avd->set_placard_image_dimensions($image_info['width'], $image_info['height']);
     }
     $embed_markup = $avd->get_embedding_markup($this->_entity);
     if (!empty($embed_markup)) {
         $this->show_item_default('File Preview', $embed_markup);
         if ($embed_markup == strip_tags($embed_markup, REASON_DEFAULT_ALLOWED_TAGS)) {
             $this->show_item_default('Embed Code', '<textarea rows="7">' . htmlspecialchars($embed_markup) . '</textarea>');
         } else {
             $this->show_item_default('Embed Code', 'Not available<div class="smallText">(The code used to embed ' . $this->_entity->get_value('media_format') . ' files may not be accepted in a Reason content area.)</div>');
         }
     }
     $link_url = REASON_HTTP_BASE_PATH . 'displayers/av_display.php?id=' . htmlspecialchars($this->_entity->id());
     $this->show_item_default('Link', '<a href="' . $link_url . '" target="_blank">Link to video</a>');
     // Everything Else
     $this->show_all_values($this->_entity->get_values());
     $this->end_table();
 }
 /**
  * Generates and returns the html markup used to represent an audio media work.
  *
  * @access private
  * @return string embed markup
  */
 private function _get_audio_embed_markup()
 {
     $markup = '<audio id="' . $this->media_work->id() . '" preload="metadata" ';
     if ($this->show_controls) {
         $markup .= 'controls="controls" ';
     }
     if ($this->autostart) {
         $markup .= 'autoplay="autoplay" ';
     }
     $markup .= '>';
     $es = new entity_selector();
     $es->add_type(id_of('av_file'));
     $es->add_right_relationship($this->media_work->id(), relationship_id_of('av_to_av_file'));
     $es->set_order('av.mime_type ASC');
     // 'mpeg' comes before 'ogg'
     $this->media_files = $es->run_one();
     $mp3 = false;
     foreach ($this->media_files as $file) {
         $markup .= '<source src="' . $this->_match_protocol($file->get_value('url')) . '" type="' . $file->get_value('mime_type') . '" />' . "\n";
         if ($file->get_value('mime_type') == 'audio/mpeg') {
             $mp3 = $file;
         }
     }
     // Fall back to flash player
     if ($mp3) {
         $avd = new reasonAVDisplay();
         $avd_autoplay = $this->autostart ? 'true' : 'false';
         $avd->set_parameter('flv', 'autostart', $avd_autoplay);
         if (!$this->show_controls) {
             $avd->set_parameter('flv', 'controlbar', '0');
         }
         $mp3->set_value('url', $this->_match_protocol($mp3->get_value('url')));
         $avd_markup = $avd->get_embedding_markup_For_flash_video($mp3);
         $markup .= $avd_markup;
         // return $avd_markup;  // uncomment this if testing the flash player
     }
     $markup .= '</audio>' . "\n";
     return $markup;
 }
 /**
  * Returns the html markup that can embed the media on a page.
  * @return string
  */
 public function get_embed_markup()
 {
     if (!$this->media_work) {
         return '';
     }
     if ($this->current_media_file) {
         $avd = new reasonAVDisplay();
         $height = $this->get_embed_height();
         $width = $this->get_embed_width();
         $avd->set_video_dimensions($width, $height);
         $avd->set_audio_dimensions(0, 0);
         if (!$this->show_controls) {
             $avd->set_parameter('flv', 'controlbar', 'false');
             $avd->set_parameter('qt', 'controller', '0');
             $avd->set_parameter('wmv', 'ShowControls', 'false');
         }
         if (!$this->autostart) {
             $avd->disable_automatic_play_start();
         }
         if ($image_info = reason_get_media_placard_image_info($this->current_media_file)) {
             $avd->set_placard_image($image_info['url']);
             $avd->set_placard_image_dimensions($image_info['width'], $image_info['height']);
         }
         $this->latest_tech_note = $avd->get_tech_note($this->current_media_file);
         $embed_markup = $avd->get_embedding_markup($this->current_media_file);
         return $embed_markup;
     } else {
         return '';
     }
 }
 function get_av_info($media_works_id, $width = 400, $height = 300, $crop_style = "fill")
 {
     $ret = array();
     //the object that gets returned
     $this->media_works_id = $media_works_id;
     $this->width = $width;
     $this->height = $height;
     $this->crop_style = $crop_style;
     $media_work = new entity($this->media_works_id);
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($media_works_id, relationship_id_of('av_to_primary_image'));
     $images = $es->run_one();
     $this->img_results = $images;
     if (count($images) > 0) {
         $image = current($images);
         $av_img_url = $this->get_av_img_url($image);
         $ret['av_img_url'] = $av_img_url;
         //set the av_image_alt to the image description
         $ret['av_img_alt'] = $image->get_value('description');
         $ret['av_img_id'] = $image->get_value('id');
     } else {
         /**
          * This is not working
          */
         //get a blank image with a play button blitted into it
         // set the av_image_alt to "play"
         $ret['av_img_url'] = $this->get_watermark_relative_path($this->media_works_type);
         if ($this->use_absolute_urls) {
             $ret['av_img_url'] = '//' . HTTP_HOST_NAME . $ret['av_img_url'];
         }
         $ret['av_img_alt'] = "play";
         $ret['av_img_id'] = "none";
     }
     if ($media_work->get_value('integration_library') && $media_work->get_value('integration_library') != 'default') {
         reason_include_once('classes/media/factory.php');
         $displayer_chrome = MediaWorkFactory::displayer_chrome($media_work, 'default');
         if ($displayer_chrome) {
             $displayer_chrome->set_media_work($media_work);
             $displayer_chrome->set_media_height($height);
             $displayer_chrome->set_media_width($width);
             $ret['av_html'] = $displayer_chrome->get_html_markup();
             $ret['type'] = $media_work->get_value('av_type');
             $ret['format'] = 'HTML5';
         } else {
             // TODO: test this?
             $ret['av_html'] = '<p>Not available.</p>';
             $ret['type'] = $media_work->get_value('av_type');
             $ret['format'] = 'HTML5';
         }
     } else {
         $avd = new reasonAVDisplay();
         $es = new entity_selector();
         $es->add_type(id_of('av_file'));
         $es->add_right_relationship($media_works_id, relationship_id_of('av_to_av_file'));
         $es->set_order('av.media_format ASC, av.av_part_number ASC');
         $results = $es->run_one();
         $this->avf_results = $results;
         $avf = null;
         $taf = array();
         $taf = $this->get_type_and_format();
         $avf = $this->get_avf($taf['type'], $taf['format']);
         $ret['type'] = $taf['type'];
         $ret['format'] = $taf['format'];
         $this->media_works_type = $taf['type'];
         $avd->set_video_dimensions($width, $height);
         $avd->disable_automatic_play_start();
         if (!empty($image)) {
             $avd->set_placard_image($image);
             // This could be an entity, an ID, or a URL string
             //get the image with a play button blitted into it
         }
         $embed_markup = "";
         if ($avf != null) {
             $embed_markup = $avd->get_embedding_markup($avf);
         }
         $ret['av_html'] = $embed_markup;
     }
     return $ret;
 }
} else {
    $id = $_GET['id'];
    settype($id, 'integer');
    $GLOBALS['_reason_media_popup_data'] = array();
    $GLOBALS['_reason_media_popup_data']['id'] = $id;
    include_once 'reason_header.php';
    reason_include_once('classes/entity.php');
    reason_include_once('classes/av_display.php');
    reason_include_once('function_libraries/file_finders.php');
    $e = new entity($id);
    if ($e->get_value('type') != id_of('av_file')) {
        trigger_error('ID passed to av_display is not for a media file');
        die;
    }
    if ($e->get_value('url')) {
        $avd = new reasonAVDisplay();
        $embed_markup = $avd->get_embedding_markup($id);
        if (empty($embed_markup)) {
            $embed_markup = '<a href="' . $e->get_value('url') . '">' . $e->get_value('url') . '</a>';
        } else {
            $tech_note = $avd->get_tech_note($id);
            if (!empty($tech_note)) {
                $embed_markup .= '<div class="techNote">' . $tech_note . '</div>' . "\n";
            }
        }
    } else {
        $embed_markup = 'Please contact site maintainer for this file (No URL provided)';
    }
    $GLOBALS['_reason_media_popup_data']['embed_markup'] = $embed_markup;
    $rel = $e->get_right_relationship('av_to_av_file');
    if ($rel) {