MediaRSS

From A-SMIL.org
Revision as of 05:14, 24 June 2009 by SMIL T.A. (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

One way to convert a media RSS feed into a SMIL feed is to use the PHP XPath library.

<?php
 
        $doc = new DOMDocument();
 
        if( $doc->load('http://rss.server.com/mediarssfeed') ) // place your feed here
        {
                $xpath = new DOMXPath($doc);
                $xpath->registerNamespace("media",
                        "http://search.yahoo.com/mrss/");
                $nodes = $xpath->query('/rss/channel/item/media:content',$doc);
                $ttlnode= $xpath->query('/rss/channel/ttl',$doc);
 
                header( 'Content-Type: application/smil' );
 
                echo "<smil><head>"
                        .'<layout><root-layout width="1280" height="720"/>'
                        .'</layout><meta http-equiv="Refresh" content="'
                        .$ttlnode->item(0)->textContent * 60
                        .'"/></head>'
                        ."<body><seq repeatCount=\"indefinite\">\r\n" ;
 
                foreach( $nodes as $node )
                {
                        echo "\t<img src=\""
                                . $node->attributes->getNamedItem('url')
                                ->textContent
                                . "\" dur=\""
                                . $node->attributes->getNamedItem('duration')
                                ->textContent
                                . "\" />\r\n" ;
                }
 
                echo '</seq></body></smil>' ;
        }
 
?>