/** * Ensure there is a playlist capable player available */ public function validate_players() { global $pagenow, $plugin_page; // only on admin.php?page=page-brightcove-playlists if ($pagenow != 'admin.php' || $plugin_page != 'page-brightcove-playlists') { return; } $player_api = new BC_Player_Management_API(); $players = $player_api->player_list_playlist_enabled(); if (is_wp_error($players) || !is_array($players) || $players['item_count'] < 1) { BC_Utility::admin_notice_messages(array(array('message' => __('A specified Source does not have a playlist capable player <a href="https://studio.brightcove.com/products/videocloud/players/">configured</a>. Make sure there is at least one player with "Display Playlist" enabled.', 'brightcove'), 'type' => 'error'))); } }
/** * Render Player * * Renders the player from Brightcove based on passed parameters * * @since 1.0 * * @param string $type "playlist" or "video". * @param string $id The brightcove player or video ID. * @param string $account_id The Brightcove account ID. * @param string $player_id The brightcove player ID. * @param int $width The Width to display. * @param int $height The height to display. * * @return string The HTML code for the player */ public static function player($type, $id, $account_id, $player_id = 'default', $width = 0, $height = 0) { // Sanitize and Verify. $account_id = BC_Utility::sanitize_id($account_id); $player_id = 'default' == $player_id ? 'default' : BC_Utility::sanitize_id($player_id); $id = BC_Utility::sanitize_id($id); $height = (int) $height; $width = (int) $width; $type = 'playlist' === $type ? 'playlist' : 'video'; if ('playlist' === $type && 'default' === $player_id) { $player_api = new BC_Player_Management_API(); $players = $player_api->player_list_playlist_enabled(); if (is_wp_error($players) || !is_array($players) || $players['item_count'] < 1) { return '<div class="brightcove-player-warning">' . __('A specified Source does not have a playlist capable player <a href="https://studio.brightcove.com/products/videocloud/players/">configured</a>. Make sure there is at least one player with "Display Playlist" enabled.', 'brightcove') . '</div>'; } $player_id = esc_attr($players['items'][0]['id']); } $html = '<!-- Start of Brightcove Player -->'; if (0 === $width && 0 === $height) { $html .= '<div style="display: block; position: relative; max-width: 100%;"><div style="padding-top: 56.25%;">'; } $html .= sprintf('<iframe src="//players.brightcove.net/%s/%s_default/index.html?%sId=%s" allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen="" style="width: %s; height: %s;%s"></iframe>', $account_id, $player_id, $type, $id, 0 === $width ? '100%' : $width . 'px', 0 === $height ? '100%' : $height . 'px', 0 === $width && 0 === $height ? 'position: absolute; top: 0px; bottom: 0px; right: 0px; left: 0px;' : ''); if (0 === $width && 0 === $height) { $html .= '</div></div>'; } $html .= '<!-- End of Brightcove Player -->'; return $html; }