/**
  * Generates and returns the html markup used to represent a video media work.  Uses html5 video
  * tags with a flash player fallback.
  *
  * @access private
  * @return string embed markup
  */
 private function _get_video_embed_markup()
 {
     // change preload to "none" to allow poster support in IE9...
     $markup = '<video id="' . $this->media_work->id() . '" preload="metadata" ';
     if ($this->show_controls) {
         $markup .= 'controls="controls" ';
     }
     if ($this->autostart) {
         $markup .= 'autoplay="autoplay" ';
     }
     $embed_width = $this->get_embed_width();
     $embed_height = $this->get_embed_height();
     // $markup .= 'width="'.intval($embed_width).'" ';
     // $markup .= 'height="'.intval($embed_height).'" ';
     $markup .= 'width="100%" ';
     // for responsiveness, fill the iframe the video is in.
     $markup .= 'height="100%" ';
     if ($poster_url = $this->_get_poster_image_url()) {
         $markup .= 'poster="' . $poster_url . '" ';
     }
     $markup .= '>' . "\n";
     $this->media_files = $this->_get_suitable_flavors($embed_width, $embed_height);
     $mp4 = null;
     foreach ($this->media_files as $media_file) {
         // Grab the largest available mp4 media file to use in the flash fallback
         if ($mp4 == null && $media_file->get_value('mime_type') == 'video/mp4') {
             $mp4 = $media_file;
         }
         $markup .= $this->_get_video_source_tag($media_file, $media_file->get_value('mime_type'));
     }
     if ($mp4 != null) {
         // Flash Video Fallback markup
         $avd = new reasonAVDisplay();
         $avd->set_video_dimensions($embed_width, $embed_height);
         $avd_autoplay = $this->autostart ? 'true' : 'false';
         $avd->set_parameter('flv', 'autostart', $avd_autoplay);
         $avd->set_parameter('flv', 'controlbar', 'over');
         if ($poster_url) {
             $avd->set_placard_image($poster_url);
         }
         if (!$this->show_controls) {
             $avd->set_parameter('flv', 'controlbar', '0');
         }
         //$mp4->set_value('media_format', 'Flash Video');
         $mp4->set_value('url', $this->_match_protocol($mp4->get_value('url')));
         $avd_markup = $avd->get_embedding_markup_for_flash_video($mp4);
         // return $avd_markup; // uncomment this if testing the flash player
         $markup .= $avd_markup;
     }
     $markup .= '</video>' . "\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 '';
     }
 }
 /**
  * Generates and returns the html markup used to represent a video media work.  Uses html5 video
  * tags with a flash player fallback.
  *
  * @access private
  * @return string embed markup
  */
 private function _get_video_embed_markup()
 {
     // change preload to "none" to allow poster support in IE9...
     $markup = '<video id="' . $this->media_work->id() . '" preload="metadata" ';
     if ($this->show_controls) {
         $markup .= 'controls="controls" ';
     }
     if ($this->autostart) {
         $markup .= 'autoplay="autoplay" ';
     }
     // specify width and height attributes explicitly in the video tag every time
     // this is needed 1) so the browswer doesn't have to figure it out(?), 2) so the placard image
     // works nicely, and 3) so the flash video player is properly scaled because it doesn't automatically scale itself.
     $embed_width = $this->get_embed_width();
     $embed_height = $this->get_embed_height();
     $markup .= 'width="' . intval($embed_width) . '" ';
     $markup .= 'height="' . intval($embed_height) . '" ';
     if ($poster_url = $this->_get_poster_image_url()) {
         $markup .= 'poster="' . $poster_url . '" ';
     }
     $markup .= '>' . "\n";
     $this->media_files = $this->_get_suitable_flavors($embed_width, $embed_height);
     $mp4 = null;
     foreach ($this->media_files as $media_file) {
         // Grab the largest available mp4 media file to use in the flash fallback
         if ($mp4 == null && $media_file->get_value('mime_type') == 'video/mp4') {
             $mp4 = $media_file;
         }
         $markup .= $this->_get_video_source_tag($media_file, $media_file->get_value('mime_type'));
     }
     if ($mp4 != null) {
         // Flash Video Fallback markup
         $avd = new reasonAVDisplay();
         $avd->set_video_dimensions($embed_width, $embed_height);
         $avd_autoplay = $this->autostart ? 'true' : 'false';
         $avd->set_parameter('flv', 'autostart', $avd_autoplay);
         $avd->set_parameter('flv', 'controlbar', 'over');
         if ($poster_url) {
             $avd->set_placard_image($poster_url);
         }
         if (!$this->show_controls) {
             $avd->set_parameter('flv', 'controlbar', '0');
         }
         //$mp4->set_value('media_format', 'Flash Video');
         $mp4->set_value('url', $this->_match_protocol($mp4->get_value('url') . '/a.mp4'));
         $avd_markup = $avd->get_embedding_markup_for_flash_video($mp4);
         //return $avd_markup; // uncomment this if testing the flash player
         $markup .= $avd_markup;
     }
     $markup .= '</video>' . "\n";
     return $markup;
 }
Пример #4
0
 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;
 }