public function get_hash(int $key = 0)
$hashes = $this->get_hashes();
if (isset($hashes[$key])) {
* @return string[]|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(int $key = 0)
$keywords = $this->get_keywords();
if (isset($keywords[$key])) {
public function get_keywords()
if ($this->keywords !== null) {
* @return ?int Length in bytes
public function get_length()
if ($this->length !== null) {
public function get_link()
if ($this->link !== null) {
* @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(int $key = 0)
$ratings = $this->get_ratings();
if (isset($ratings[$key])) {
public function get_ratings()
if ($this->ratings !== null) {
* Get a single restriction
* @return \SimplePie\Restriction|null
public function get_restriction(int $key = 0)
$restrictions = $this->get_restrictions();
if (isset($restrictions[$key])) {
return $restrictions[$key];
* @return Restriction[]|null
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(int $key = 0)
$thumbnails = $this->get_thumbnails();
if (isset($thumbnails[$key])) {
return $thumbnails[$key];
* @return string[]|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, mixed>|string $options See first parameter 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, mixed>|string $options Comma-separated key:value list, or array
* @param bool $native Use `<embed>`
* @return string HTML string to output
public function embed($options = '', bool $native = false)
$handler = $this->get_handler();
$type = $this->get_real_type();
// Process options and reassign values as necessary
if (is_array($options)) {
$options = explode(',', $options);
foreach ($options as $option) {
$opt = explode(':', $option, 2);
if (isset($opt[0], $opt[1])) {
$mime = explode('/', (string) $type, 2);
// Process values for 'auto'
if ($height === 'auto') {
$width = round((intval($height) / 9) * 16);
$width = round((intval($height) / 3) * 4);
if ($height === 'auto') {
} elseif ($mime === 'video') {
$height = round((intval($width) / 16) * 9);
$height = round((intval($width) / 4) * 3);
} elseif ($mime === 'audio') {
// Set proper placeholder value
} elseif ($mime === 'video') {
if ($handler === 'flash') {
$embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
$embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
// Flash Media Player file types.
// Preferred handler for MP3 file types.
elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) {
if (is_numeric($height)) {
$embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";