Is there any way to have the player continue playing a track the visitor chose while they navigate to other pages (either on my site or elsewhere)?
This is a vital requirement yet so little information is available on how to accomplish it.
Thank you.
]]>Hi, I’m excited about the CD baby embed, but I’ve noticed that when I insert the sample code [cdbaby type=”full” transparenent=”true”]56c85363-b435-48b0-9b20-0edffd191681[/cdbaby] it interferes with all the content below on the page after updating. It also effects the side widget areas as the become invisible. Can you help? You can visit my site https://www.joymusic.eu/music-store/ for verification of these problems…
]]>I’m having trouble placing the shortcode for CD Baby plugin, and I would appreciate your help. Please do not refer me to the plugin description page, as it has proved useless to me.
1. The plugin description site shows four examples of shortcode that begin with [cdbaby] and end with [/cdbaby]. The shortcode I got, however, does not have that.
2. The shortcode I got is this: <iframe name=”full” style=”width:100%;height:520px;border:0px;” src=”https://widget.cdbaby.com/83ae92cd-56da-4644-9c7a-13716742bd34/full/dark/opaque”></iframe>
3. At the WordPress Editor page for the CD Baby plugin, there is a ton of cryptic instructions, codes and information, but there is NO precise indication of WHERE EXACTLY the shortcode shown above should go. What line? After what word or what asterisk or what? Should the shortcode above be wrapped with [cdbaby] and [/cdbaby]?
4. I tried placing it somewhere near line 12 and the whole WP Dashboard went kaput. Even my blog (claudiolessa.com) went bad, until I erased the plugin folder. Only then things got back to normal.
5. Now I have the plugin installed again, but not activated, and I don’t want to try fiddling with the WordPress Editor until I have precise instructions. I just want to avoid the risk of another site meltdown.
Thank you very much in advance for your attention and possible cooperation.
Claudio Lessa
in Brasilia, Brazil
[email protected]
(THIS IS THE SHORTCODE)
<iframe name=”full” style=”width:100%;height:520px;border:0px;” src=”https://widget.cdbaby.com/9639ed8d-06f5-407f-9194-2788c283e1e7/full/dark/opaque”></iframe>
(IS THIS THE PAGE WHERE THE SHORTCODE SHOULD BE INSERTED?
W H E R E, E X A C T L Y?)
<?php
/*
Plugin Name: CD Baby Music Player Shortcode
Plugin URI: https://www.ads-software.com/extend/plugins/cdbaby-shortcode/
Description: Embeds the CD Baby HTML5 Player into WordPress using the cdbaby shortcode. Example: [cdbaby]DA770544-7C91-45D9-8372-104BCD7FB47F[/cdbaby]
Version: 1.0.3
Author: CD Baby
Author URI: https://cdbaby.com
License: GPLv2
*/
/* Register shortcode*/
add_shortcode(‘cdbaby’, ‘cdbaby_shortcode’);
/**
* CD Baby (cdbaby) shortcode.
*
* This implements the functionality of the playlist shortcode for displaying
* a collection of WordPress audio or video files in a post.
*
* @param {string|array} $attr CD Baby shortcode attributes.
* @param string $content Content (typically the playerId) passed within [cdbaby] tags.
* @return string Music Player HTML.
*/
function cdbaby_shortcode($atts, $content = null) {
// Custom shortcode options
$shortcode_options = is_array($atts) ? $atts : array();
if ($content != NULL){
$shortcode_options = array_merge(array(‘playerid’ => trim($content)), $shortcode_options);
}
// Default options
$default_options = array(
‘width’ => ‘100%’,
‘height’ => ‘100px’,
‘type’ => ‘mini’, // mini|album|square|full
‘theme’ => ‘light’, // light|dark
‘transparent’ => ‘false’ // true|false
);
// shortcode options
$options = array_merge( $default_options, $shortcode_options);
// The “playerId” option is required
if (!isset($options[‘playerid’])) {
return ‘<p>CD Baby Player ID not found</p>’;
} else {
$options[‘playerId’] = trim($options[‘playerid’]);
}
return create_player($options);
}
/**
* Create Player Emded code.
*
* Output Player HTML
*
* @param {array} $options Player options
* @return string Music Player HTML.
*/
function create_player($options) {
// Base URL without last slash
$base = ‘//widget.cdbaby.com’;
// Build URL
$url = sprintf(‘%s/%s/%s/%s/%s’, $base, $options[‘playerId’], $options[‘type’], $options[‘theme’], $options[‘transparent’]);
// Set default width if not defined
$width = isset($options[‘width’]) && $options[‘width’] !== 0 ? $options[‘width’] : ‘100%’;
// Set default height if not defined
$height = isset($options[‘height’]) && $options[‘height’] !== 0 ? $options[‘height’] : ‘100px’;
switch ($options[‘type’]) {
case ‘mini’:
return sprintf(‘<iframe name=”mini” style=”border:0px;width:%s;height:%s;” src=”%s”></iframe>’, $width, $height, $url);
case ‘album’:
return sprintf(‘<div style=”max-width:600px;max-height:760px;”><div style=”position: relative;height: 0;overflow: hidden;padding-bottom:calc(100%% + 200px);”><iframe name=”album” style=”position:absolute;top:0px;left:0px;width:100%%;height:100%%;border:0px;” src=”%s”></iframe></div></div>’, $url);
case ‘square’:
return sprintf(‘<div style=”max-width:600px;max-height:625px;”><div style=”position: relative;height: 0;overflow: hidden;padding-bottom:calc(100%% + 30px);”><iframe name=”square” style=”position:absolute;top:0px;left:0px;width:100%%;height:100%%;border:0px;” src=”%s”></iframe></div></div>’, $url);
case ‘full’:
return sprintf(‘<iframe name=”full” style=”width:100%%;height:520px;border:0px;” src=”%s”/>’, $url);
}
}
function is_valid_guid($id){
return preg_match(‘/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/’, trim($id)) > 0;
}
?>
On what exact line of the WordPress editor should I insert the code I copied from CD Baby? This is the exact code I got:
<iframe name=”full” style=”width:100%;height:520px;border:0px;” src=”https://widget.cdbaby.com/83ae92cd-56da-4644-9c7a-13716742bd34/full/dark/opaque”></iframe>
Please note that the code above does not follow the examples provided with the [cdbaby]start and [/cdbaby]ending.
Thanks in advance for any help.
Claudio Lessa
]]>Hi. This plugin is a great idea – really pleased to see that CD Baby has put it together, A couple issues I’m having…
My host does not allow iframes, so I’m using the plugin to embed the player, and it works as indicated; however, I have no control over the size, other than the built in parameters. If my content area is bigger than 600px but I want the player to be 300px, how do I accomplish that?
Also, WordPress users seem to be a very creative type, and will definitely want control over the players colors, not just the light, dark and transparency options currently offered. That would be a most welcome upgrade ??