SimplePie_Enclosure

Handles everything related to enclosures (including Media RSS and iTunes RSS).

Defined (1)

The class is defined in the following location(s).

/wp-includes/SimplePie/Enclosure.php  
  1. class SimplePie_Enclosure 
  2. /** 
  3. * @var string 
  4. * @see get_bitrate() 
  5. */ 
  6. var $bitrate; 
  7.  
  8. /** 
  9. * @var array 
  10. * @see get_captions() 
  11. */ 
  12. var $captions; 
  13.  
  14. /** 
  15. * @var array 
  16. * @see get_categories() 
  17. */ 
  18. var $categories; 
  19.  
  20. /** 
  21. * @var int 
  22. * @see get_channels() 
  23. */ 
  24. var $channels; 
  25.  
  26. /** 
  27. * @var SimplePie_Copyright 
  28. * @see get_copyright() 
  29. */ 
  30. var $copyright; 
  31.  
  32. /** 
  33. * @var array 
  34. * @see get_credits() 
  35. */ 
  36. var $credits; 
  37.  
  38. /** 
  39. * @var string 
  40. * @see get_description() 
  41. */ 
  42. var $description; 
  43.  
  44. /** 
  45. * @var int 
  46. * @see get_duration() 
  47. */ 
  48. var $duration; 
  49.  
  50. /** 
  51. * @var string 
  52. * @see get_expression() 
  53. */ 
  54. var $expression; 
  55.  
  56. /** 
  57. * @var string 
  58. * @see get_framerate() 
  59. */ 
  60. var $framerate; 
  61.  
  62. /** 
  63. * @var string 
  64. * @see get_handler() 
  65. */ 
  66. var $handler; 
  67.  
  68. /** 
  69. * @var array 
  70. * @see get_hashes() 
  71. */ 
  72. var $hashes; 
  73.  
  74. /** 
  75. * @var string 
  76. * @see get_height() 
  77. */ 
  78. var $height; 
  79.  
  80. /** 
  81. * @deprecated 
  82. * @var null 
  83. */ 
  84. var $javascript; 
  85.  
  86. /** 
  87. * @var array 
  88. * @see get_keywords() 
  89. */ 
  90. var $keywords; 
  91.  
  92. /** 
  93. * @var string 
  94. * @see get_language() 
  95. */ 
  96. var $lang; 
  97.  
  98. /** 
  99. * @var string 
  100. * @see get_length() 
  101. */ 
  102. var $length; 
  103.  
  104. /** 
  105. * @var string 
  106. * @see get_link() 
  107. */ 
  108. var $link; 
  109.  
  110. /** 
  111. * @var string 
  112. * @see get_medium() 
  113. */ 
  114. var $medium; 
  115.  
  116. /** 
  117. * @var string 
  118. * @see get_player() 
  119. */ 
  120. var $player; 
  121.  
  122. /** 
  123. * @var array 
  124. * @see get_ratings() 
  125. */ 
  126. var $ratings; 
  127.  
  128. /** 
  129. * @var array 
  130. * @see get_restrictions() 
  131. */ 
  132. var $restrictions; 
  133.  
  134. /** 
  135. * @var string 
  136. * @see get_sampling_rate() 
  137. */ 
  138. var $samplingrate; 
  139.  
  140. /** 
  141. * @var array 
  142. * @see get_thumbnails() 
  143. */ 
  144. var $thumbnails; 
  145.  
  146. /** 
  147. * @var string 
  148. * @see get_title() 
  149. */ 
  150. var $title; 
  151.  
  152. /** 
  153. * @var string 
  154. * @see get_type() 
  155. */ 
  156. var $type; 
  157.  
  158. /** 
  159. * @var string 
  160. * @see get_width() 
  161. */ 
  162. var $width; 
  163.  
  164. /** 
  165. * Constructor, used to input the data 
  166. * For documentation on all the parameters, see the corresponding 
  167. * properties and their accessors 
  168. * @uses idna_convert If available, this will convert an IDN 
  169. */ 
  170. public function __construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) 
  171. $this->bitrate = $bitrate; 
  172. $this->captions = $captions; 
  173. $this->categories = $categories; 
  174. $this->channels = $channels; 
  175. $this->copyright = $copyright; 
  176. $this->credits = $credits; 
  177. $this->description = $description; 
  178. $this->duration = $duration; 
  179. $this->expression = $expression; 
  180. $this->framerate = $framerate; 
  181. $this->hashes = $hashes; 
  182. $this->height = $height; 
  183. $this->keywords = $keywords; 
  184. $this->lang = $lang; 
  185. $this->length = $length; 
  186. $this->link = $link; 
  187. $this->medium = $medium; 
  188. $this->player = $player; 
  189. $this->ratings = $ratings; 
  190. $this->restrictions = $restrictions; 
  191. $this->samplingrate = $samplingrate; 
  192. $this->thumbnails = $thumbnails; 
  193. $this->title = $title; 
  194. $this->type = $type; 
  195. $this->width = $width; 
  196.  
  197. if (class_exists('idna_convert')) 
  198. $idn = new idna_convert(); 
  199. $parsed = SimplePie_Misc::parse_url($link); 
  200. $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); 
  201. $this->handler = $this->get_handler(); // Needs to load last 
  202.  
  203. /** 
  204. * String-ified version 
  205. * @return string 
  206. */ 
  207. public function __toString() 
  208. // There is no $this->data here 
  209. return md5(serialize($this)); 
  210.  
  211. /** 
  212. * Get the bitrate 
  213. * @return string|null 
  214. */ 
  215. public function get_bitrate() 
  216. if ($this->bitrate !== null) 
  217. return $this->bitrate; 
  218. else 
  219. return null; 
  220.  
  221. /** 
  222. * Get a single caption 
  223. * @param int $key 
  224. * @return SimplePie_Caption|null 
  225. */ 
  226. public function get_caption($key = 0) 
  227. $captions = $this->get_captions(); 
  228. if (isset($captions[$key])) 
  229. return $captions[$key]; 
  230. else 
  231. return null; 
  232.  
  233. /** 
  234. * Get all captions 
  235. * @return array|null Array of {@see SimplePie_Caption} objects 
  236. */ 
  237. public function get_captions() 
  238. if ($this->captions !== null) 
  239. return $this->captions; 
  240. else 
  241. return null; 
  242.  
  243. /** 
  244. * Get a single category 
  245. * @param int $key 
  246. * @return SimplePie_Category|null 
  247. */ 
  248. public function get_category($key = 0) 
  249. $categories = $this->get_categories(); 
  250. if (isset($categories[$key])) 
  251. return $categories[$key]; 
  252. else 
  253. return null; 
  254.  
  255. /** 
  256. * Get all categories 
  257. * @return array|null Array of {@see SimplePie_Category} objects 
  258. */ 
  259. public function get_categories() 
  260. if ($this->categories !== null) 
  261. return $this->categories; 
  262. else 
  263. return null; 
  264.  
  265. /** 
  266. * Get the number of audio channels 
  267. * @return int|null 
  268. */ 
  269. public function get_channels() 
  270. if ($this->channels !== null) 
  271. return $this->channels; 
  272. else 
  273. return null; 
  274.  
  275. /** 
  276. * Get the copyright information 
  277. * @return SimplePie_Copyright|null 
  278. */ 
  279. public function get_copyright() 
  280. if ($this->copyright !== null) 
  281. return $this->copyright; 
  282. else 
  283. return null; 
  284.  
  285. /** 
  286. * Get a single credit 
  287. * @param int $key 
  288. * @return SimplePie_Credit|null 
  289. */ 
  290. public function get_credit($key = 0) 
  291. $credits = $this->get_credits(); 
  292. if (isset($credits[$key])) 
  293. return $credits[$key]; 
  294. else 
  295. return null; 
  296.  
  297. /** 
  298. * Get all credits 
  299. * @return array|null Array of {@see SimplePie_Credit} objects 
  300. */ 
  301. public function get_credits() 
  302. if ($this->credits !== null) 
  303. return $this->credits; 
  304. else 
  305. return null; 
  306.  
  307. /** 
  308. * Get the description of the enclosure 
  309. * @return string|null 
  310. */ 
  311. public function get_description() 
  312. if ($this->description !== null) 
  313. return $this->description; 
  314. else 
  315. return null; 
  316.  
  317. /** 
  318. * Get the duration of the enclosure 
  319. * @param string $convert Convert seconds into hh:mm:ss 
  320. * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) 
  321. */ 
  322. public function get_duration($convert = false) 
  323. if ($this->duration !== null) 
  324. if ($convert) 
  325. $time = SimplePie_Misc::time_hms($this->duration); 
  326. return $time; 
  327. else 
  328. return $this->duration; 
  329. else 
  330. return null; 
  331.  
  332. /** 
  333. * Get the expression 
  334. * @return string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full' 
  335. */ 
  336. public function get_expression() 
  337. if ($this->expression !== null) 
  338. return $this->expression; 
  339. else 
  340. return 'full'; 
  341.  
  342. /** 
  343. * Get the file extension 
  344. * @return string|null 
  345. */ 
  346. public function get_extension() 
  347. if ($this->link !== null) 
  348. $url = SimplePie_Misc::parse_url($this->link); 
  349. if ($url['path'] !== '') 
  350. return pathinfo($url['path'], PATHINFO_EXTENSION); 
  351. return null; 
  352.  
  353. /** 
  354. * Get the framerate (in frames-per-second) 
  355. * @return string|null 
  356. */ 
  357. public function get_framerate() 
  358. if ($this->framerate !== null) 
  359. return $this->framerate; 
  360. else 
  361. return null; 
  362.  
  363. /** 
  364. * Get the preferred handler 
  365. * @return string|null One of 'flash', 'fmedia', 'quicktime', 'wmedia', 'mp3' 
  366. */ 
  367. public function get_handler() 
  368. return $this->get_real_type(true); 
  369.  
  370. /** 
  371. * Get a single hash 
  372. * @link http://www.rssboard.org/media-rss#media-hash 
  373. * @param int $key 
  374. * @return string|null Hash as per `media:hash`, prefixed with "$algo:" 
  375. */ 
  376. public function get_hash($key = 0) 
  377. $hashes = $this->get_hashes(); 
  378. if (isset($hashes[$key])) 
  379. return $hashes[$key]; 
  380. else 
  381. return null; 
  382.  
  383. /** 
  384. * Get all credits 
  385. * @return array|null Array of strings, see {@see get_hash()} 
  386. */ 
  387. public function get_hashes() 
  388. if ($this->hashes !== null) 
  389. return $this->hashes; 
  390. else 
  391. return null; 
  392.  
  393. /** 
  394. * Get the height 
  395. * @return string|null 
  396. */ 
  397. public function get_height() 
  398. if ($this->height !== null) 
  399. return $this->height; 
  400. else 
  401. return null; 
  402.  
  403. /** 
  404. * Get the language 
  405. * @link http://tools.ietf.org/html/rfc3066 
  406. * @return string|null Language code as per RFC 3066 
  407. */ 
  408. public function get_language() 
  409. if ($this->lang !== null) 
  410. return $this->lang; 
  411. else 
  412. return null; 
  413.  
  414. /** 
  415. * Get a single keyword 
  416. * @param int $key 
  417. * @return string|null 
  418. */ 
  419. public function get_keyword($key = 0) 
  420. $keywords = $this->get_keywords(); 
  421. if (isset($keywords[$key])) 
  422. return $keywords[$key]; 
  423. else 
  424. return null; 
  425.  
  426. /** 
  427. * Get all keywords 
  428. * @return array|null Array of strings 
  429. */ 
  430. public function get_keywords() 
  431. if ($this->keywords !== null) 
  432. return $this->keywords; 
  433. else 
  434. return null; 
  435.  
  436. /** 
  437. * Get length 
  438. * @return float Length in bytes 
  439. */ 
  440. public function get_length() 
  441. if ($this->length !== null) 
  442. return $this->length; 
  443. else 
  444. return null; 
  445.  
  446. /** 
  447. * Get the URL 
  448. * @return string|null 
  449. */ 
  450. public function get_link() 
  451. if ($this->link !== null) 
  452. return urldecode($this->link); 
  453. else 
  454. return null; 
  455.  
  456. /** 
  457. * Get the medium 
  458. * @link http://www.rssboard.org/media-rss#media-content 
  459. * @return string|null Should be one of 'image', 'audio', 'video', 'document', 'executable' 
  460. */ 
  461. public function get_medium() 
  462. if ($this->medium !== null) 
  463. return $this->medium; 
  464. else 
  465. return null; 
  466.  
  467. /** 
  468. * Get the player URL 
  469. * Typically the same as {@see get_permalink()} 
  470. * @return string|null Player URL 
  471. */ 
  472. public function get_player() 
  473. if ($this->player !== null) 
  474. return $this->player; 
  475. else 
  476. return null; 
  477.  
  478. /** 
  479. * Get a single rating 
  480. * @param int $key 
  481. * @return SimplePie_Rating|null 
  482. */ 
  483. public function get_rating($key = 0) 
  484. $ratings = $this->get_ratings(); 
  485. if (isset($ratings[$key])) 
  486. return $ratings[$key]; 
  487. else 
  488. return null; 
  489.  
  490. /** 
  491. * Get all ratings 
  492. * @return array|null Array of {@see SimplePie_Rating} objects 
  493. */ 
  494. public function get_ratings() 
  495. if ($this->ratings !== null) 
  496. return $this->ratings; 
  497. else 
  498. return null; 
  499.  
  500. /** 
  501. * Get a single restriction 
  502. * @param int $key 
  503. * @return SimplePie_Restriction|null 
  504. */ 
  505. public function get_restriction($key = 0) 
  506. $restrictions = $this->get_restrictions(); 
  507. if (isset($restrictions[$key])) 
  508. return $restrictions[$key]; 
  509. else 
  510. return null; 
  511.  
  512. /** 
  513. * Get all restrictions 
  514. * @return array|null Array of {@see SimplePie_Restriction} objects 
  515. */ 
  516. public function get_restrictions() 
  517. if ($this->restrictions !== null) 
  518. return $this->restrictions; 
  519. else 
  520. return null; 
  521.  
  522. /** 
  523. * Get the sampling rate (in kHz) 
  524. * @return string|null 
  525. */ 
  526. public function get_sampling_rate() 
  527. if ($this->samplingrate !== null) 
  528. return $this->samplingrate; 
  529. else 
  530. return null; 
  531.  
  532. /** 
  533. * Get the file size (in MiB) 
  534. * @return float|null File size in mebibytes (1048 bytes) 
  535. */ 
  536. public function get_size() 
  537. $length = $this->get_length(); 
  538. if ($length !== null) 
  539. return round($length/1048576, 2); 
  540. else 
  541. return null; 
  542.  
  543. /** 
  544. * Get a single thumbnail 
  545. * @param int $key 
  546. * @return string|null Thumbnail URL 
  547. */ 
  548. public function get_thumbnail($key = 0) 
  549. $thumbnails = $this->get_thumbnails(); 
  550. if (isset($thumbnails[$key])) 
  551. return $thumbnails[$key]; 
  552. else 
  553. return null; 
  554.  
  555. /** 
  556. * Get all thumbnails 
  557. * @return array|null Array of thumbnail URLs 
  558. */ 
  559. public function get_thumbnails() 
  560. if ($this->thumbnails !== null) 
  561. return $this->thumbnails; 
  562. else 
  563. return null; 
  564.  
  565. /** 
  566. * Get the title 
  567. * @return string|null 
  568. */ 
  569. public function get_title() 
  570. if ($this->title !== null) 
  571. return $this->title; 
  572. else 
  573. return null; 
  574.  
  575. /** 
  576. * Get mimetype of the enclosure 
  577. * @see get_real_type() 
  578. * @return string|null MIME type 
  579. */ 
  580. public function get_type() 
  581. if ($this->type !== null) 
  582. return $this->type; 
  583. else 
  584. return null; 
  585.  
  586. /** 
  587. * Get the width 
  588. * @return string|null 
  589. */ 
  590. public function get_width() 
  591. if ($this->width !== null) 
  592. return $this->width; 
  593. else 
  594. return null; 
  595.  
  596. /** 
  597. * Embed the enclosure using `<embed>` 
  598. * @deprecated Use the second parameter to {@see embed} instead 
  599. * @param array|string $options See first paramter to {@see embed} 
  600. * @return string HTML string to output 
  601. */ 
  602. public function native_embed($options='') 
  603. return $this->embed($options, true); 
  604.  
  605. /** 
  606. * Embed the enclosure using Javascript 
  607. * `$options` is an array or comma-separated key:value string, with the 
  608. * following properties: 
  609. * - `alt` (string): Alternate content for when an end-user does not have 
  610. * the appropriate handler installed or when a file type is 
  611. * unsupported. Can be any text or HTML. Defaults to blank. 
  612. * - `altclass` (string): If a file type is unsupported, the end-user will 
  613. * see the alt text (above) linked directly to the content. That link 
  614. * will have this value as its class name. Defaults to blank. 
  615. * - `audio` (string): This is an image that should be used as a 
  616. * placeholder for audio files before they're loaded (QuickTime-only). 
  617. * Can be any relative or absolute URL. Defaults to blank. 
  618. * - `bgcolor` (string): The background color for the media, if not 
  619. * already transparent. Defaults to `#ffffff`. 
  620. * - `height` (integer): The height of the embedded media. Accepts any 
  621. * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,  
  622. * and it is recommended that you use this default. 
  623. * - `loop` (boolean): Do you want the media to loop when its done? 
  624. * Defaults to `false`. 
  625. * - `mediaplayer` (string): The location of the included 
  626. * `mediaplayer.swf` file. This allows for the playback of Flash Video 
  627. * (`.flv`) files, and is the default handler for non-Odeo MP3's. 
  628. * Defaults to blank. 
  629. * - `video` (string): This is an image that should be used as a 
  630. * placeholder for video files before they're loaded (QuickTime-only). 
  631. * Can be any relative or absolute URL. Defaults to blank. 
  632. * - `width` (integer): The width of the embedded media. Accepts any 
  633. * numeric pixel value (such as `480`) or `auto`. Defaults to `auto`,  
  634. * and it is recommended that you use this default. 
  635. * - `widescreen` (boolean): Is the enclosure widescreen or standard? 
  636. * This applies only to video enclosures, and will automatically resize 
  637. * the content appropriately. Defaults to `false`, implying 4:3 mode. 
  638. * Note: Non-widescreen (4:3) mode with `width` and `height` set to `auto` 
  639. * will default to 480x360 video resolution. Widescreen (16:9) mode with 
  640. * `width` and `height` set to `auto` will default to 480x270 video resolution. 
  641. * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. 
  642. * @param array|string $options Comma-separated key:value list, or array 
  643. * @param bool $native Use `<embed>` 
  644. * @return string HTML string to output 
  645. */ 
  646. public function embed($options = '', $native = false) 
  647. // Set up defaults 
  648. $audio = ''; 
  649. $video = ''; 
  650. $alt = ''; 
  651. $altclass = ''; 
  652. $loop = 'false'; 
  653. $width = 'auto'; 
  654. $height = 'auto'; 
  655. $bgcolor = '#ffffff'; 
  656. $mediaplayer = ''; 
  657. $widescreen = false; 
  658. $handler = $this->get_handler(); 
  659. $type = $this->get_real_type(); 
  660.  
  661. // Process options and reassign values as necessary 
  662. if (is_array($options)) 
  663. extract($options); 
  664. else 
  665. $options = explode(', ', $options); 
  666. foreach($options as $option) 
  667. $opt = explode(':', $option, 2); 
  668. if (isset($opt[0], $opt[1])) 
  669. $opt[0] = trim($opt[0]); 
  670. $opt[1] = trim($opt[1]); 
  671. switch ($opt[0]) 
  672. case 'audio': 
  673. $audio = $opt[1]; 
  674. break; 
  675.  
  676. case 'video': 
  677. $video = $opt[1]; 
  678. break; 
  679.  
  680. case 'alt': 
  681. $alt = $opt[1]; 
  682. break; 
  683.  
  684. case 'altclass': 
  685. $altclass = $opt[1]; 
  686. break; 
  687.  
  688. case 'loop': 
  689. $loop = $opt[1]; 
  690. break; 
  691.  
  692. case 'width': 
  693. $width = $opt[1]; 
  694. break; 
  695.  
  696. case 'height': 
  697. $height = $opt[1]; 
  698. break; 
  699.  
  700. case 'bgcolor': 
  701. $bgcolor = $opt[1]; 
  702. break; 
  703.  
  704. case 'mediaplayer': 
  705. $mediaplayer = $opt[1]; 
  706. break; 
  707.  
  708. case 'widescreen': 
  709. $widescreen = $opt[1]; 
  710. break; 
  711.  
  712. $mime = explode('/', $type, 2); 
  713. $mime = $mime[0]; 
  714.  
  715. // Process values for 'auto' 
  716. if ($width === 'auto') 
  717. if ($mime === 'video') 
  718. if ($height === 'auto') 
  719. $width = 480; 
  720. elseif ($widescreen) 
  721. $width = round((intval($height)/9)*16); 
  722. else 
  723. $width = round((intval($height)/3)*4); 
  724. else 
  725. $width = '100%'; 
  726.  
  727. if ($height === 'auto') 
  728. if ($mime === 'audio') 
  729. $height = 0; 
  730. elseif ($mime === 'video') 
  731. if ($width === 'auto') 
  732. if ($widescreen) 
  733. $height = 270; 
  734. else 
  735. $height = 360; 
  736. elseif ($widescreen) 
  737. $height = round((intval($width)/16)*9); 
  738. else 
  739. $height = round((intval($width)/4)*3); 
  740. else 
  741. $height = 376; 
  742. elseif ($mime === 'audio') 
  743. $height = 0; 
  744.  
  745. // Set proper placeholder value 
  746. if ($mime === 'audio') 
  747. $placeholder = $audio; 
  748. elseif ($mime === 'video') 
  749. $placeholder = $video; 
  750.  
  751. $embed = ''; 
  752.  
  753. // Flash 
  754. if ($handler === 'flash') 
  755. if ($native) 
  756. $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>"; 
  757. else 
  758. $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>"; 
  759.  
  760. // Flash Media Player file types. 
  761. // Preferred handler for MP3 file types. 
  762. elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) 
  763. $height += 20; 
  764. if ($native) 
  765. $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>"; 
  766. else 
  767. $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>"; 
  768.  
  769. // QuickTime 7 file types. Need to test with QuickTime 6. 
  770. // Only handle MP3's if the Flash Media Player is not present. 
  771. elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) 
  772. $height += 16; 
  773. if ($native) 
  774. if ($placeholder !== '') 
  775. $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 
  776. else 
  777. $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 
  778. else 
  779. $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>"; 
  780.  
  781. // Windows Media 
  782. elseif ($handler === 'wmedia') 
  783. $height += 45; 
  784. if ($native) 
  785. $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>"; 
  786. else 
  787. $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>"; 
  788.  
  789. // Everything else 
  790. else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>'; 
  791.  
  792. return $embed; 
  793.  
  794. /** 
  795. * Get the real media type 
  796. * Often, feeds lie to us, necessitating a bit of deeper inspection. This 
  797. * converts types to their canonical representations based on the file 
  798. * extension 
  799. * @see get_type() 
  800. * @param bool $find_handler Internal use only, use {@see get_handler()} instead 
  801. * @return string MIME type 
  802. */ 
  803. public function get_real_type($find_handler = false) 
  804. // Mime-types by handler. 
  805. $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash 
  806. $types_fmedia = array('video/flv', 'video/x-flv', 'flv-application/octet-stream'); // Flash Media Player 
  807. $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime 
  808. $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media 
  809. $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 
  810.  
  811. if ($this->get_type() !== null) 
  812. $type = strtolower($this->type); 
  813. else 
  814. $type = null; 
  815.  
  816. // If we encounter an unsupported mime-type, check the file extension and guess intelligently. 
  817. if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) 
  818. switch (strtolower($this->get_extension())) 
  819. // Audio mime-types 
  820. case 'aac': 
  821. case 'adts': 
  822. $type = 'audio/acc'; 
  823. break; 
  824.  
  825. case 'aif': 
  826. case 'aifc': 
  827. case 'aiff': 
  828. case 'cdda': 
  829. $type = 'audio/aiff'; 
  830. break; 
  831.  
  832. case 'bwf': 
  833. $type = 'audio/wav'; 
  834. break; 
  835.  
  836. case 'kar': 
  837. case 'mid': 
  838. case 'midi': 
  839. case 'smf': 
  840. $type = 'audio/midi'; 
  841. break; 
  842.  
  843. case 'm4a': 
  844. $type = 'audio/x-m4a'; 
  845. break; 
  846.  
  847. case 'mp3': 
  848. case 'swa': 
  849. $type = 'audio/mp3'; 
  850. break; 
  851.  
  852. case 'wav': 
  853. $type = 'audio/wav'; 
  854. break; 
  855.  
  856. case 'wax': 
  857. $type = 'audio/x-ms-wax'; 
  858. break; 
  859.  
  860. case 'wma': 
  861. $type = 'audio/x-ms-wma'; 
  862. break; 
  863.  
  864. // Video mime-types 
  865. case '3gp': 
  866. case '3gpp': 
  867. $type = 'video/3gpp'; 
  868. break; 
  869.  
  870. case '3g2': 
  871. case '3gp2': 
  872. $type = 'video/3gpp2'; 
  873. break; 
  874.  
  875. case 'asf': 
  876. $type = 'video/x-ms-asf'; 
  877. break; 
  878.  
  879. case 'flv': 
  880. $type = 'video/x-flv'; 
  881. break; 
  882.  
  883. case 'm1a': 
  884. case 'm1s': 
  885. case 'm1v': 
  886. case 'm15': 
  887. case 'm75': 
  888. case 'mp2': 
  889. case 'mpa': 
  890. case 'mpeg': 
  891. case 'mpg': 
  892. case 'mpm': 
  893. case 'mpv': 
  894. $type = 'video/mpeg'; 
  895. break; 
  896.  
  897. case 'm4v': 
  898. $type = 'video/x-m4v'; 
  899. break; 
  900.  
  901. case 'mov': 
  902. case 'qt': 
  903. $type = 'video/quicktime'; 
  904. break; 
  905.  
  906. case 'mp4': 
  907. case 'mpg4': 
  908. $type = 'video/mp4'; 
  909. break; 
  910.  
  911. case 'sdv': 
  912. $type = 'video/sd-video'; 
  913. break; 
  914.  
  915. case 'wm': 
  916. $type = 'video/x-ms-wm'; 
  917. break; 
  918.  
  919. case 'wmv': 
  920. $type = 'video/x-ms-wmv'; 
  921. break; 
  922.  
  923. case 'wvx': 
  924. $type = 'video/x-ms-wvx'; 
  925. break; 
  926.  
  927. // Flash mime-types 
  928. case 'spl': 
  929. $type = 'application/futuresplash'; 
  930. break; 
  931.  
  932. case 'swf': 
  933. $type = 'application/x-shockwave-flash'; 
  934. break; 
  935.  
  936. if ($find_handler) 
  937. if (in_array($type, $types_flash)) 
  938. return 'flash'; 
  939. elseif (in_array($type, $types_fmedia)) 
  940. return 'fmedia'; 
  941. elseif (in_array($type, $types_quicktime)) 
  942. return 'quicktime'; 
  943. elseif (in_array($type, $types_wmedia)) 
  944. return 'wmedia'; 
  945. elseif (in_array($type, $types_mp3)) 
  946. return 'mp3'; 
  947. else 
  948. return null; 
  949. else 
  950. return $type;