sort_enclosures($order = array('flash', 'quicktime', 'wmedia')) { /* * If an item contains multiple formats (i.e. Google Video), allow the user to prefer one handler over another (prefer Flash Video over QuickTime). * If multiple file types have the same handler, sort those file types in feed order. Prefer the value over other values. * For example: if an item contains .mov, .mp4, .flv, .avi, and .wmv, the default sorting (flash, quicktime, windows media, no handler), would reset the enclosure order to .flv, .mov, .mp4, .wmv, and .avi * Preferential sorting can be disabled by passing false as the parameter. * Should preferential sorting be on by default? It would certainly be handy, but people may be used to the default sorting order. */ return true } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ($enclosure = $item->get_enclosure($key)) { /* * Because Media RSS has s, one "enclosure" can have several versions of the same content (if we define an enclosure as a piece of content rather than just a file) * If there are zero s, we can simply handle these are get_enclosure(0), get_enclosure(1), etc. Each enlosure would be treated as separate content. * If there is one s, we can simply handle these are get_enclosure(0)->get_link(0), get_enclosure(0)->get_link(1), etc. would be handled as part of this * If there are two or more s, we can simply handle these are get_enclosure(0)->get_link(0), get_enclosure(0)->get_link(1), etc. First would be handled as part of the first , the second would group with the second, etc. (It would really help to have a test feed for this to see if the solution makes sense.) Problems: * is on a per-content basis. Perhaps in the case of zero or one s, we can simply apply this same thumbnail to all files. * What do we do if there are multiple s? Logically, we would support them the same way we do multiple enclosures, but then we have multiple[multiple] enclosures/groups. Possible Solution: * We can have enclosures with (possibly) multiple links. We can handle this as $enclosure->get_link($key=0), with only one $enclosure->get_thumbnail(), and multiple categories as $enclosure->get_category($key=0) (like we do with items). * It is around this solution that I'm writing the following pseudocode. * Another possible solution would be to have other functions that are specific to MediaRSS/iTunes (i.e. $item->media_group(0)->get_link(0)) that would allow power users to have the kind of control they want. The standard enclosure() object (which would essentially be the easier-to-use version) would simply use the first file available (after obeying $feed->sort_enclosures(), , etc.) */ $enclosure->get_extension($key = 0) { /* * Return the file extension of $this->get_link() with any query strings stripped off */ } $enclosure->get_length($key = 0) { /* * Return the length in bytes */ if (enclosure_tag) { return value of } else if (media_tag) { return value of } } $enclosure->get_link($key = 0) { /* * Return the URL(s) of the enclosure */ if (enclosure_tag) { return value of } else if (media_tag) { return value of } } $enclosure->get_size($key = 0) { /* * Return value of $this->get_length(), converted to mebibytes (which are commonly mistaken to be megabytes). This is the most common/useful value for most audio/video files (few are usefully measured in KB, and fewer in GB). */ return ($this->get_length()/1024)/1024 } $enclosure->get_type($key = 0) { /* * Return the mime type of the content */ if (enclosure_tag) { return value of } else if (media_tag) { return value of } } $enclosure->get_handler($key = 0) { /* * Return the correct handler for the file * Useful for those who are writing their own embed code and don't want to do the mime-type/file-type processing that we already handle in embed(). As a matter of fact, that code should probably be pulled out into this function, and embed() would simply call it when necessary. */ return the correct handler for the content type (flash || flashmediaplayer || odeo || quicktime || windowsmedia) } $enclosure->get_duration($key = 0) { /* * Returns the amount of time (in seconds) the audio/video content takes to consume */ if (media_tag) { return } else if (itunes_tag) { return } } $enclosure->get_rating($key = 0) { /* * Returns the rating of the content * Media RSS can specify the kind of rating. iTunes only cares whether content is explicit, non-explicit, or clean. * has been deprecated */ if (media_tag) { return array( 'scheme' => 'icra', 'value' => 'r (cz 1 lz 1 nz 1 oz 1 vz 1)' ); } else if (itunes_tag) { return array( 'scheme' => 'explicit', 'value' => 'no' ); } } /* THERE ARE OTHER MEDIA RSS AND ITUNES ELEMENTS AVAILABLE. MAP THEM TOGETHER AS IT MAKES SENSE. */ $enclosure->get_extra_data($key = 0) { /* * Return additional data that may be available for a file * Probably most valuable for Media RSS */ return array( 'bitrate' => '128', 'expression' => 'full', 'framerate' => '25', 'samplingrate' => '44.1' // etc. ); } } ?>