* Get the preferred handler
* @return string|null One of 'flash', 'fmedia', 'quicktime', 'wmedia', 'mp3'
public function get_handler()
return $this->get_real_type(true);
* @link http://www.rssboard.org/media-rss#media-hash
* @return string|null Hash as per `media:hash`, prefixed with "$algo:"
public function get_hash($key = 0)
$hashes = $this->get_hashes();
if (isset($hashes[$key]))
* @return array|null Array of strings, see {@see get_hash()}
public function get_hashes()
if ($this->hashes !== null)
public function get_height()
if ($this->height !== null)
* @link http://tools.ietf.org/html/rfc3066
* @return string|null Language code as per RFC 3066
public function get_language()
if ($this->lang !== null)
public function get_keyword($key = 0)
$keywords = $this->get_keywords();
if (isset($keywords[$key]))
* @return array|null Array of strings
public function get_keywords()
if ($this->keywords !== null)
* @return float Length in bytes
public function get_length()
if ($this->length !== null)
public function get_link()
if ($this->link !== null)
return urldecode($this->link);
* @link http://www.rssboard.org/media-rss#media-content
* @return string|null Should be one of 'image', 'audio', 'video', 'document', 'executable'
public function get_medium()
if ($this->medium !== null)
* Typically the same as {@see get_permalink()}
* @return string|null Player URL
public function get_player()
if ($this->player !== null)
* @return SimplePie_Rating|null
public function get_rating($key = 0)
$ratings = $this->get_ratings();
if (isset($ratings[$key]))
* @return array|null Array of {@see SimplePie_Rating} objects
public function get_ratings()
if ($this->ratings !== null)
* Get a single restriction
* @return SimplePie_Restriction|null
public function get_restriction($key = 0)
$restrictions = $this->get_restrictions();
if (isset($restrictions[$key]))
return $restrictions[$key];
* @return array|null Array of {@see SimplePie_Restriction} objects
public function get_restrictions()
if ($this->restrictions !== null)
return $this->restrictions;
* Get the sampling rate (in kHz)
public function get_sampling_rate()
if ($this->samplingrate !== null)
return $this->samplingrate;
* Get the file size (in MiB)
* @return float|null File size in mebibytes (1048 bytes)
public function get_size()
$length = $this->get_length();
return round($length/1048576, 2);
* @return string|null Thumbnail URL
public function get_thumbnail($key = 0)
$thumbnails = $this->get_thumbnails();
if (isset($thumbnails[$key]))
return $thumbnails[$key];
* @return array|null Array of thumbnail URLs
public function get_thumbnails()
if ($this->thumbnails !== null)
return $this->thumbnails;
public function get_title()
if ($this->title !== null)
* Get mimetype of the enclosure
* @return string|null MIME type
public function get_type()
if ($this->type !== null)
public function get_width()
if ($this->width !== null)
* Embed the enclosure using `<embed>`
* @deprecated Use the second parameter to {@see embed} instead
* @param array|string $options See first paramter to {@see embed}
* @return string HTML string to output
public function native_embed($options='')
return $this->embed($options, true);
* Embed the enclosure using Javascript
* `$options` is an array or comma-separated key:value string, with the
* - `alt` (string): Alternate content for when an end-user does not have
* the appropriate handler installed or when a file type is
* unsupported. Can be any text or HTML. Defaults to blank.
* - `altclass` (string): If a file type is unsupported, the end-user will
* see the alt text (above) linked directly to the content. That link
* will have this value as its class name. Defaults to blank.
* - `audio` (string): This is an image that should be used as a
* placeholder for audio files before they're loaded (QuickTime-only).
* Can be any relative or absolute URL. Defaults to blank.
* - `bgcolor` (string): The background color for the media, if not
* already transparent. Defaults to `#ffffff`.
* - `height` (integer): The height of the embedded media. Accepts any
* numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
* and it is recommended that you use this default.
* - `loop` (boolean): Do you want the media to loop when it's done?
* - `mediaplayer` (string): The location of the included
* `mediaplayer.swf` file. This allows for the playback of Flash Video
* (`.flv`) files, and is the default handler for non-Odeo MP3's.
* - `video` (string): This is an image that should be used as a
* placeholder for video files before they're loaded (QuickTime-only).
* Can be any relative or absolute URL. Defaults to blank.
* - `width` (integer): The width of the embedded media. Accepts any
* numeric pixel value (such as `480`) or `auto`. Defaults to `auto`,
* and it is recommended that you use this default.
* - `widescreen` (boolean): Is the enclosure widescreen or standard?
* This applies only to video enclosures, and will automatically resize
* the content appropriately. Defaults to `false`, implying 4:3 mode.
* Note: Non-widescreen (4:3) mode with `width` and `height` set to `auto`
* will default to 480x360 video resolution. Widescreen (16:9) mode with
* `width` and `height` set to `auto` will default to 480x270 video resolution.
* @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
* @param array|string $options Comma-separated key:value list, or array
* @param bool $native Use `<embed>`
* @return string HTML string to output
public function embed($options = '', $native = false)
$handler = $this->get_handler();
$type = $this->get_real_type();
// Process options and reassign values as necessary
$options = explode(',', $options);
foreach($options as $option)
$opt = explode(':', $option, 2);
if (isset($opt[0], $opt[1]))
$mime = explode('/', $type, 2);
// Process values for 'auto'
$width = round((intval($height)/9)*16);
$width = round((intval($height)/3)*4);