function run()
 {
     if ($this->media_work->get_value('integration_library') == 'kaltura') {
         // Kill the module if the media work is somehow not a media work video
         if ($this->media_work->get_value('av_type') != 'Video' || $this->admin_page->type_id != id_of('av')) {
             die('<p>This module only works with Media Works whose av_type is \'Video\'.</p>');
         }
         // Kill the module if the user doesn't have access to the video
         $mwh = new media_work_helper($this->media_work);
         if (!$mwh->user_has_access_to_media()) {
             die('<p>You do not have permissions to change the still frame for this video.</p>');
         }
         if ($this->cur_image) {
             echo '<p>This Media Work\'s current placard image is displayed below:</p>' . "\n";
             echo '<img src="' . reason_get_image_url($this->cur_image) . '">' . "\n";
             echo '<hr />' . "\n";
             $choose_img_link = carl_make_redirect(array('cur_module' => 'Associator', 'rel_id' => relationship_id_of('av_to_primary_image')));
             echo '<h4><a href="' . $choose_img_link . '">Choose your own image.</a></h4>' . "\n";
             echo '<h3>OR</h3>' . "\n";
             echo '<h4>Use the slider below to choose a different still frame from the video to use as its placard image.</h4>' . "\n";
         } else {
             echo '<h4>Choose your own image to use as its placard image.</h4>' . "\n";
             echo '<h2>OR</h2>' . "\n";
             echo '<h4>Use the slider below to choose a still frame from the video to use as its placard image.</h4>' . "\n";
         }
         $this->run_form();
     } else {
         die('<p>This module only applies to kaltura-integrated Media Works.</p>');
     }
 }
 function run()
 {
     if ($this->media_work->get_value('integration_library') == 'kaltura') {
         // Kill the module if the user doesn't have access to the video
         $mwh = new media_work_helper($this->media_work);
         if (!$mwh->user_has_access_to_media()) {
             die('<p>You do not have permission to view the download links for this media work.</p>');
         }
         echo '<p>All download links for "' . $this->media_work->get_value('name') . '" are displayed below.</p>' . "\n";
         echo '<ul>' . "\n";
         $file_ext = $this->kaltura_shim->get_source_file_extension($this->media_work);
         echo '<li><a href="' . $this->kaltura_shim->get_original_data_url($this->media_work->get_value('entry_id')) . '">Original (.' . $file_ext . ')</a></li>' . "\n";
         foreach ($this->media_files as $file) {
             echo '<li><a href="' . $file->get_value('download_url') . '">' . $file->get_value('name') . '</a></li>' . "\n";
         }
         echo '</ul>' . "\n";
     } else {
         die('<p>This module only applies to kaltura-integrated Media Works.</p>');
     }
 }
Пример #3
0
 /**
  * Returns the html markup to simply display the media.
  * @return string
  */
 public function get_html_markup()
 {
     $markup = '';
     if ($this->media_work->get_value('entry_id')) {
         if (!empty($this->request['displayer_height'])) {
             $height = $this->request['displayer_height'];
         } else {
             $height = $this->av_module->params['default_video_height'];
         }
         $this->displayer->set_height($height);
         $embed_markup = $this->displayer->get_display_markup();
         $markup .= $embed_markup;
         $mwh = new media_work_helper($this->media_work);
         if ($mwh->user_has_access_to_media()) {
             $markup .= $this->size_selector->get_size_selector_html($this->media_work, $height);
             $markup .= '<div class="share_download_info">' . "\n";
             $markup .= '<div class="share">' . "\n";
             $markup .= '<h5 class="share_label">Share:</h5>' . "\n";
             $markup .= '<ul class="share_list">' . "\n";
             $facebook_url = 'http://www.facebook.com/sharer.php?u=' . urlencode(get_current_url()) . '&t=' . urlencode($this->media_work->get_value('name'));
             $markup .= '<li><a href="' . $facebook_url . '">Facebook</a></li>' . "\n";
             $twitter_url = 'https://twitter.com/share?url=' . urlencode(get_current_url()) . '&text=' . urlencode($this->media_work->get_value('name'));
             $markup .= '<li><a href="' . $twitter_url . '">Twitter</a></li>' . "\n";
             $markup .= '</ul>' . "\n";
             $markup .= '</div>' . "\n";
             if ($this->media_work->get_value('show_embed')) {
                 $markup .= '<div class="embed">' . "\n";
                 $markup .= '<h5 class="embed_label">Embed:</h5>' . "\n";
                 $markup .= '<textarea class="embed_code" rows="7" cols="75" readonly="readonly">' . "\n";
                 $markup .= htmlspecialchars($embed_markup, ENT_QUOTES);
                 $markup .= '</textarea>' . "\n";
                 $markup .= '</div>' . "\n";
             }
             $markup .= '</div>' . "\n";
         }
     } else {
         $markup .= '<p>Sorry, this media work cannot be displayed.</p>' . "\n";
     }
     return $markup;
 }
 function run()
 {
     // Kill the module if the media work is somehow not a media work video
     if ($this->media_work->get_value('integration_library') != 'zencoder' || $this->media_work->get_value('av_type') != 'Video' || $this->admin_page->type_id != id_of('av')) {
         die('<p>This module only works with Zencoder-integrated Media Works whose av_type is \'Video\'.</p>');
     }
     // Kill the module if the user doesn't have access to the video
     $mwh = new media_work_helper($this->media_work);
     if (!$mwh->user_has_access_to_media()) {
         die('<p>You do not have permissions to change the still frame for this video.</p>');
     }
     if (count($this->get_images()) == 0) {
         die('<p>There are no thumbnails for this media work. Attach an image to this media work if you want to assign it a thumbnail.</p>' . "\n");
     }
     if ($this->cur_image) {
         echo '<p>This Media Work\'s current thumbnail is displayed below:</p>' . "\n";
         echo '<img src="' . reason_get_image_url($this->cur_image) . '">' . "\n";
         echo '<hr />' . "\n";
         $choose_img_link = carl_make_redirect(array('cur_module' => 'Associator', 'rel_id' => relationship_id_of('av_to_primary_image')));
         echo '<h4><a href="' . $choose_img_link . '">Choose your own image.</a></h4>' . "\n";
         echo '<h3>OR</h3>' . "\n";
         echo '<h4>Use the slider below to choose a different still frame from the video to use as its thumbnail.</h4>' . "\n";
     } else {
         echo '<h4>Choose your own image to use as its placard image.</h4>' . "\n";
         echo '<h2>OR</h2>' . "\n";
         echo '<h4>Use the slider below to choose a still frame from the video to use as its thumbnail.</h4>' . "\n";
     }
     if (count($this->get_images()) > 1) {
         echo '<p>There are ' . count($this->get_images()) . ' images to choose from.</p>' . "\n";
     } elseif (count($this->get_images()) == 1) {
         echo '<p>There is only one image to choose from.</p>' . "\n";
     } else {
         echo '<p>There are no images to choose from.</p>' . "\n";
     }
     // provide data for javascript magic
     echo $this->get_js_data();
     $this->run_form();
 }
} else {
    http_response_code(404);
    die;
}
if ($displayer->get_hash() != $hash) {
    http_response_code(404);
    die;
}
# Grab the media_work's associated group if it has one
$es = new entity_selector();
$es->add_type(id_of('group_type'));
$es->add_right_relationship($media_work->id(), relationship_id_of('av_restricted_to_group'));
$group = current($es->run_one());
$extension = $media_file->get_value('av_type') == 'Video' ? 'mp4' : 'mp3';
# If the user doesn't have access to the media work, header to the "No Access" url
$mwh = new media_work_helper($media_work);
if (!$mwh->user_has_access_to_media()) {
    $username = reason_require_http_authentication();
    if (!$mwh->user_has_access_to_media($username)) {
        // header to the access denied media
        header('Location: http://' . HTTP_HOST_NAME . REASON_HTTP_BASE_PATH . 'modules/av/no_access_message.' . $extension);
        die;
    }
}
# If we make it here, the podcast is safe to provide
$file_url = $media_file->get_value('url');
// ask the shim if we need to do a url hack to allow iTunes to import the file
$shim = MediaWorkFactory::shim($media_work);
if ($shim) {
    if ($shim->requires_extension_for_podcast()) {
        $extra_extension = '/a.' . $extension;
Пример #6
0
    /**
     * Returns the html markup to display the media with share/download info.
     * @return string
     */
    public function get_html_markup()
    {
        $markup = '';
        if ($this->media_work->get_value('transcoding_status') == 'ready') {
            if (!empty($this->request['displayer_height'])) {
                $height = $this->request['displayer_height'];
            } else {
                $height = $this->av_module->params['default_video_height'];
            }
            $this->displayer->set_height($height);
            $embed_markup = $this->displayer->get_display_markup();
            $markup .= $embed_markup;
            $mwh = new media_work_helper($this->media_work);
            if ($mwh->user_has_access_to_media()) {
                if ($this->media_work->get_value('av_type') == 'Video') {
                    $markup .= $this->size_selector->get_size_selector_html($this->media_work, $height);
                }
                $markup .= '<div class="share_download_info">' . "\n";
                $markup .= '<div class="share">' . "\n";
                $markup .= '<h5 class="share_label">Share:</h5>' . "\n";
                $markup .= '<ul class="share_list">' . "\n";
                $facebook_url = 'http://www.facebook.com/sharer.php?u=' . urlencode(get_current_url()) . '&t=' . urlencode($this->media_work->get_value('name'));
                $markup .= '<li><a href="' . $facebook_url . '">Facebook</a></li>' . "\n";
                $twitter_url = 'https://twitter.com/share?url=' . urlencode(get_current_url()) . '&text=' . urlencode($this->media_work->get_value('name'));
                $markup .= '<li><a href="' . $twitter_url . '">Twitter</a></li>' . "\n";
                $markup .= '</ul>' . "\n";
                $markup .= '</div>' . "\n";
                if ($this->media_work->get_value('show_embed')) {
                    $markup .= '<div class="embed">' . "\n";
                    $markup .= '<h5 class="embed_label">Embed:</h5>' . "\n";
                    $markup .= '<textarea class="embed_code" rows="7" cols="75" readonly="readonly">' . "\n";
                    $markup .= htmlspecialchars($embed_markup, ENT_QUOTES);
                    $markup .= '</textarea>' . "\n";
                    $markup .= '</div>' . "\n";
                }
                if ($this->media_work->get_value('show_download')) {
                    $markup .= '<div class="download">' . "\n";
                    $markup .= '<h5 class="download_label">Download:</h5>' . "\n";
                    $markup .= '<ul class="media_file_list">' . "\n";
                    // Offer an original file download link if this parameter is set
                    if ($this->av_module->params['offer_original_download_link'] && !empty($this->shim)) {
                        $file_ext = $this->shim->get_source_file_extension($this->media_work);
                        if ($orig_url = $this->shim->get_original_data_url($this->media_work->get_value('entry_id'))) {
                            $markup .= '<li class="orig_li"><a href="' . $orig_url . '"">original (.' . $file_ext . ')</a></li>' . "\n";
                        }
                    }
                    if ($this->media_work->get_value('av_type') == 'Video') {
                        // We must provide the url for each size here so that the javascript has a hook for the download links.
                        $mp4_vals = array();
                        $webm_vals = array();
                        $small_av_files = $this->displayer->_get_suitable_flavors(MEDIA_WORK_SMALL_HEIGHT, MEDIA_WORK_SMALL_HEIGHT);
                        $small_mp4 = $small_av_files[0];
                        $mp4_vals['small'] = $small_mp4->get_value('download_url');
                        $small_webm = $small_av_files[1];
                        $webm_vals['small'] = $small_webm->get_value('download_url');
                        $medium_av_files = $this->displayer->_get_suitable_flavors(MEDIA_WORK_MEDIUM_HEIGHT, MEDIA_WORK_MEDIUM_HEIGHT);
                        $med_mp4 = $medium_av_files[0];
                        $mp4_vals['medium'] = $med_mp4->get_value('download_url');
                        $med_webm = $medium_av_files[1];
                        $webm_vals['medium'] = $med_webm->get_value('download_url');
                        $large_av_files = $this->displayer->_get_suitable_flavors(MEDIA_WORK_LARGE_HEIGHT, MEDIA_WORK_LARGE_HEIGHT);
                        $large_mp4 = $large_av_files[0];
                        $mp4_vals['large'] = $large_mp4->get_value('download_url');
                        $large_webm = $large_av_files[1];
                        $webm_vals['large'] = $large_webm->get_value('download_url');
                        $av_files = $this->displayer->get_media_files();
                        $markup .= '<li class="mp4_li"><a href="' . $av_files[0]->get_value('download_url') . '" 
											data-small-url="' . $mp4_vals['small'] . '"
											data-medium-url="' . $mp4_vals['medium'] . '"
											data-large-url="' . $mp4_vals['large'] . '">.mp4</a></li>' . "\n";
                        $markup .= '<li class="webm_li"><a href="' . $av_files[1]->get_value('download_url') . '" 
											data-small-url="' . $webm_vals['small'] . '"
											data-medium-url="' . $webm_vals['medium'] . '"
											data-large-url="' . $webm_vals['large'] . '">.webm</a></li>' . "\n";
                    } elseif ($this->media_work->get_value('av_type') == 'Audio') {
                        $av_files = $this->displayer->get_media_files();
                        foreach ($av_files as $file) {
                            $extension = $file->get_value('mime_type');
                            // people know what mp3 is, not mpeg, so we display mpegs as mp3s
                            if ($extension == 'audio/mpeg') {
                                $extension = 'audio/mp3';
                            }
                            $parts = explode('/', $extension);
                            $markup .= '<li class="' . reason_htmlspecialchars(str_replace(' ', '-', end($parts))) . '_li"><a href="' . $file->get_value('download_url') . '">.' . end($parts) . '</a></li>' . "\n";
                        }
                    }
                    $markup .= '</ul>' . "\n";
                    $markup .= '</div>' . "\n";
                }
                $markup .= '</div>' . "\n";
            }
        } else {
            if ($this->media_work->get_value('av_type') == 'Video') {
                $markup .= '<p>This video is currently processing. Try again later.</p>' . "\n";
            } elseif ($this->media_work->get_value('av_type') == 'Audio') {
                $markup .= '<p>This audio file is currently processing. Try again later.</p>' . "\n";
            } else {
                $markup .= '<p>This item is currently processing. Try again later.</p>' . "\n";
            }
        }
        return $markup;
    }