function tm_player($player = '', $args = array()) { if (empty($player) || empty($args['files'])) { return; } $defaults = array('files' => array(), 'poster' => '', 'autoplay' => false); $args = wp_parse_args($args, $defaults); extract($args); /* JWPlayer */ if ($player == 'jwplayer') { $options = array('file' => trim($files[0]), 'image' => $poster); $atts = arr2atts($options); $jwplayer_shortcode = '[jwplayer' . $atts . ']'; echo apply_filters('tm_video_filter', $jwplayer_shortcode); } elseif ($player == 'flowplayer' && function_exists('flowplayer_content_handle')) { $atts = array('splash' => $poster); foreach ($files as $key => $file) { $att = $key == 0 ? 'src' : 'src' . $key; $atts[$att] = $file; } echo flowplayer_content_handle($atts, '', ''); tm_flowplayer_script(); } elseif ($player == 'videojs' && function_exists('video_shortcode')) { $atts = array('poster' => $poster); foreach ($files as $key => $file) { $att = $key == 0 ? 'src' : 'src' . $key; if (strpos($file, '.mp4') !== false) { $atts['mp4'] = $file; } if (strpos($file, '.webm') !== false) { $atts['webm'] = $file; } if (strpos($file, '.ogg') !== false) { $atts['ogg'] = $file; } } echo video_shortcode($atts, '', ''); tm_add_videojs_swf(); } else { $atts = array(); foreach ($files as $file) { $file = trim($file); if (strpos($file, 'youtube.com') !== false) { $atts['youtube'] = $file; } else { $type = wp_check_filetype($file, wp_get_mime_types()); $atts[$type['ext']] = $file; } } echo wp_video_shortcode($atts); } }
function fv_flowplayer_shortcode_playlist($output) { $aArgs = func_get_args(); $atts = $aArgs[1]; if (!empty($atts['type']) && $atts['type'] != 'video') { return false; } // copy from wp-includes/media.php wp_playlist_shortcode() global $post; if (!empty($attr['ids'])) { // 'ids' is explicitly ordered, unless you specify otherwise. if (empty($attr['orderby'])) { $attr['orderby'] = 'post__in'; } $attr['include'] = $attr['ids']; } $atts = shortcode_atts(array('type' => 'audio', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'include' => '', 'exclude' => '', 'style' => 'light', 'tracklist' => true, 'tracknumbers' => true, 'images' => true, 'artists' => true), $atts, 'playlist'); $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $atts['type'], 'order' => $atts['order'], 'orderby' => $atts['orderby']); if (!empty($atts['include'])) { $args['include'] = $atts['include']; $_attachments = get_posts($args); if (!count($_attachments)) { return false; } $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } else { return false; } $bridge_atts = array(); $aPlaylistItems = array(); $aPlaylistImages = array(); $i = 0; foreach ($attachments as $attachment) { $i++; $url = wp_get_attachment_url($attachment->ID); if ($i == 1) { $bridge_atts['src'] = $url; } else { $aPlaylistItems[] = $url; } $thumb_id = get_post_thumbnail_id($attachment->ID); $src = false; if (!empty($thumb_id)) { list($src, $width, $height) = wp_get_attachment_image_src($thumb_id, 'thumbnail'); } if ($i == 1) { $bridge_atts['splash'] = $src; } else { $aPlaylistImages[] = $src; } } $bridge_atts['playlist'] = ''; foreach ($aPlaylistItems as $key => $src) { $bridge_atts['playlist'] .= $src; if ($aPlaylistImages[$key]) { $bridge_atts['playlist'] .= ',' . $aPlaylistImages[$key]; } $bridge_atts['playlist'] .= ';'; } $bridge_atts['playlist'] = trim($bridge_atts['playlist'], ';'); if (isset($atts['width'])) { $bridge_atts['width'] = $atts['width']; } if (isset($atts['height'])) { $bridge_atts['height'] = $atts['height']; } if (count($bridge_atts) == 0) { return "<!--FV Flowplayer video shortcode integration - no attributes recognized-->"; } return flowplayer_content_handle($bridge_atts, false, 'video'); }