前回の続き。YouTube 埋め込みプレーヤーのパラメータ – YouTube の API とツール – Google Codeを読み、サムネを埋め込みプレーヤーに変えてみた。Flashで再生させているので、先日Galaxy NexusにインストールしたChromeでは再生されなかった。
特定キーワードを検索して得られたフィードからサムネ(埋め込みプレーヤー)を表示するページ:hello_youtube02.php
$url = "http://gdata.youtube.com/feeds/api/videos?vq=skateboarding+dog";
$contents = file_get_contents($url);
$xml = simplexml_load_string($contents);
$html_table = '<table>';
foreach ($xml->entry as $entry) {
$media = $entry->children('http://search.yahoo.com/mrss/');
$attrs = $media->group->content->attributes();
$link = $attrs['url'];
$html_row = '<tr><td rowspan="3" width="120" height="90" align="center">'
. '<object style="height: 90px; width: 120px"><param name="movie" value="' . $link . '">'
. '<embed src="' . $link . '" type="application/x-shockwave-flash" width="120" height="90"></object></td>';
$title = $media->group->title;
$html_row .= '<td>' . $title . '</td></tr>';
$published = $entry->published;
$html_row .= '<tr><td>' . $published . '</td></tr>';
$yt = $entry->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->statistics->attributes();
$counter = $attrs['viewCount'];
$html_row .= '<tr><td>' . $counter . '</td></tr>';
$html_table .= $html_row;
}
$html_table .= '</table>';
print($html_table);
関連エントリー