
' . "\n";
}
return $out;
}
return generate_embed_code($atts);
}
function resolve_media_id(&$atts) {
$id = $atts["mediaid"];
$post = get_post($id);
if (!isset($atts["image"])) {
$thumbnail = get_post_meta($id, LONGTAIL_KEY . "thumbnail_url", true);
if (!isset($thumbnail) || $thumbnail == null || $thumbnail == "") {
$image_id = get_post_meta($id, LONGTAIL_KEY . "thumbnail", true);
if (isset($image_id)) {
$image_attachment = get_post($image_id);
$atts["image"] = isset($image_attachment) ? $image_attachment->guid : "";
}
} else {
$atts["image"] = $thumbnail;
}
}
$mime_type = substr($post->post_mime_type, 0, 5);
if ($mime_type == "image") {
$duration = get_post_meta($id, LONGTAIL_KEY . "duration", true);
$atts["duration"] = $duration ? $duration : 10;
$atts["image"] = $post->guid;
} else if ($mime_type == "audio") {
if (empty($atts["image"]) && empty($atts["width"]) && empty($atts["height"])) {
$atts["playerReady"] = "function(obj) { document.getElementById(obj['id']).parentNode.style.height = document.getElementById(obj['id']).getPluginConfig('controlbar')['height'] %2B 'px'; }";
$atts["icons"] = false;
$atts["controlbar"] = "bottom";
}
}
if (!isset($atts["file"])) {
$rtmp = get_post_meta($id, LONGTAIL_KEY . "rtmp");
if (isset($rtmp) && $rtmp) {
$atts["streamer"] = get_post_meta($id, LONGTAIL_KEY . "streamer", true);
$atts["file"] = get_post_meta($id, LONGTAIL_KEY . "file", true);
} else {
$atts["file"] = $post->guid;
}
}
if (!array_key_exists("html5_file", $atts)) {
if ($html5_file = retrieve_file("html5", $id)) $atts["html5_file"] = $html5_file;
}
if (!array_key_exists("download_file", $atts)) {
if ($download_file = retrieve_file("download", $id)) $atts["download_file"] = $download_file;
}
}
function generate_embed_code($atts) {
$version = version_compare(get_option(LONGTAIL_KEY . "version"), "5.3", ">=");
$embedder = file_exists(LongTailFramework::getEmbedderPath());
if (!$embedder && !$version && preg_match("/iP(od|hone|ad)/i", $_SERVER["HTTP_USER_AGENT"])) {
$youtube_pattern = "/youtube.com\/watch\?v=([0-9a-zA-Z_-]*)/i";
$loaded_config = LongTailFramework::getConfigValues();
$width = isset($atts["width"]) ? $atts["width"] : $loaded_config["width"];
$height = isset($atts["height"]) ? $atts["height"] : $loaded_config["height"];
$output = "";
if (preg_match($youtube_pattern, $atts["file"], $match)) {
$output = '';
} else {
$output = '';
}
return $output;
} else {
if (get_option(LONGTAIL_KEY . "player_location_enable")) {
$swf = LongTailFramework::generateSWFObject($atts, $embedder, get_option(LONGTAIL_KEY . "player_location"));
} else {
$swf = LongTailFramework::generateSWFObject($atts, $embedder);
}
if (!get_option(LONGTAIL_KEY . "use_head_js")) {
insert_embedder($embedder);
}
return $swf->generateEmbedScript();
}
}
function create_mode_block($atts) {
$modes = array();
$playerMode = get_option(LONGTAIL_KEY . "player_mode", true);
$flashMode = new stdClass();
$flashMode->type = "flash";
$flashMode->src = LongTailFramework::getPlayerURL();
$html5Mode = new stdClass();
$html5Mode->type = "html5";
$html5Mode->config = new stdClass();
$html5Mode->config->streamer = "";
$html5Mode->config->provider = "";
if (array_key_exists("html5_file", $atts)) $html5Mode->config->file = $atts["html5_file"];
$downloadMode = new stdClass();
$downloadMode->type = "download";
$downloadMode->config = new stdClass();
$downloadMode->config->streamer = "";
$downloadMode->config->provider = "";
if (array_key_exists("download_file", $atts)) $html5Mode->config->file = $atts["download_file"];
if ($playerMode == "html5") {
$modes[] = $html5Mode;
$modes[] = $flashMode;
} else {
$modes[] = $flashMode;
$modes[] = $html5Mode;
}
$modes[] = $downloadMode;
return $modes;
}
function generate_playlist($playlist_id) {
$output = array();
$playlist = get_post($playlist_id);
$playlist_items = "";
if ($playlist) {
$playlist_items = explode(",", get_post_meta($playlist_id, LONGTAIL_KEY . "playlist_items", true));
}
if (is_array($playlist_items)) {
foreach ($playlist_items as $playlist_item_id) {
$p_item = array();
$playlist_item = get_post($playlist_item_id);
$image_id = get_post_meta($playlist_item_id, LONGTAIL_KEY . "thumbnail", true);
$creator = get_post_meta($playlist_item_id, LONGTAIL_KEY . "creator", true);
$thumbnail = get_post_meta($playlist_item_id, LONGTAIL_KEY . "thumbnail_url", true);
$streamer = get_post_meta($playlist_item_id, LONGTAIL_KEY . "streamer", true);
$file = get_post_meta($playlist_item_id, LONGTAIL_KEY . "file", true);
$html5_file = retrieve_file("html5", $playlist_item_id);
$download_file = retrieve_file("download", $playlist_item_id);
if (empty($thumbnail)) {
$temp = get_post($image_id);
$image = isset($temp) ? $temp->guid : "";
} else {
$image = $thumbnail;
}
$p_item["title"] = $playlist_item->post_title;
$p_item["creator"] = $creator;
$p_item["author"] = $creator;
$p_item["date"] = $playlist_item->post_date;
$p_item["levels"] = array();
$flashFile = new stdClass();
if (!empty($streamer)) {
$p_item["streamer"] = $streamer;
$flashFile->file = $file;
$p_item["levels"][] = $flashFile;
} else {
$flashFile->file = $playlist_item->guid;
$p_item["levels"][] = $flashFile;
}
if ($html5_file) {
$html5File = new stdClass();
$html5File->file = $html5_file;
$p_item["levels"][] = $html5File;
}
if ($download_file) {
$downloadFile = new stdClass();
$downloadFile->file = $download_file;
$p_item["levels"][] = $downloadFile;
}
$duration = get_post_meta($playlist_item_id, LONGTAIL_KEY . "duration", true);
if ($duration) $p_item["duration"] = $duration;
if (substr($playlist_item->post_mime_type, 0, 5) == "image") {
$p_item["image"] = $playlist_item->guid;
} else {
$p_item["image"] = $image;
}
$p_item["description"] = $playlist_item->post_content;
$p_item["mediaid"] = $playlist_item_id;
$p_item["id"] = $playlist_item_id;
$output[] = $p_item;
}
}
return $output;
}
function retrieve_file($fileType, $id) {
$file = get_post_meta($id, LONGTAIL_KEY . $fileType . "_file", true);
if (!isset($file) || $file == null || $file == "") {
$file_id = get_post_meta($id, LONGTAIL_KEY . $fileType . "_file_selector", true);
if (isset($file_id) && $file_id > -1) {
$file_attachment = get_post($file_id);
$file = $file_attachment->guid;
}
}
if (!isset($file) || $file == null || $file == "") {
return false;
}
return $file;
}
function insert_embedder($embedderExists) {
if ($embedderExists) {
wp_print_scripts('jw-embedder');
} else {
wp_print_scripts('swfobject');
}
}
?>