You are here: Documentation » API Reference » SimplePie_Enclosure » embed()
embed()
Description
class SimplePie_Enclosure { embed ( [(array) $options] ) }
Embeds the enclosure into the webpage using JavaScript.
This will use get_real_type()
to determine which handler should be used to embed the content into the page. SimplePie supports QuickTime, Windows Media, Flash, Flash Media, and the Odeo Player for Odeo feeds.
Because of the fallout from the Eolas lawsuit against Microsoft and the changes that were recently made to Internet Explorer as a result, we generate and include a JavaScript library containing functions that allow us to embed the multimedia content.
This function is identical to native_embed()
except that, whereas native_embed()
writes the (invalid) embed code directly into the page, this function uses JavaScript so that your pages can validate as HTML or XHTML. Also, this function will only work properly if SimplePie is initialized at the very top of the page.
Availability
- Available since SimplePie Beta 2.
Parameters
options
options
is an array of multiple options that can all be passed into the embed() method. They are as follows:
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 as360
) orauto
. Defaults toauto
, and it is recommended that you use this default.loop
(boolean)
Do you want the media to loop when its done? Defaults tofalse
.mediaplayer
(string)
The location of the includedmediaplayer.swf
file. This allows for the playback of Flash Video (.flv
) files, and is the default handler for non-Odeo MP3's. Defaults to blank.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 as480
) orauto
. Defaults toauto
, 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 tofalse
, implying 4:3 mode.
NOTE: Non-widescreen (4:3) mode with width
and height
set to auto
will default to 480×360 video resolution. Widescreen (16:9) mode with width
and height
set to auto
will default to 480×270 video resolution.
Examples
$feed = new SimplePie(); $feed->set_feed_url('http://youtube.com/rss/global/top_favorites.rss'); $feed->init(); $feed->handle_content_type(); foreach ($feed->get_items() as $item) { if ($enclosure = $item->get_enclosure()) { echo $enclosure->embed(array( 'alt' => 'Download this enclosure!', 'audio' => './for_the_demo/place_audio.png', 'video' => './for_the_demo/place_video.png', 'mediaplayer' => './for_the_demo/mediaplayer.swf', 'widescreen' => true )); } }
See Also
reference/simplepie_enclosure/embed.txt · Last modified: 2011/03/06 03:56 (external edit)