simplemovie.mxml使用 Adobe Flex (MXML) 建立極簡播放器,透過 flashVars 接收影片 URL。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="https://www.adobe.com/2006/mxml" layout="absolute">
<mx:VBox backgroundColor="white" width="400" height="335">
<mx:VideoDisplay width="400" height="300" id="videoPlayer" source="{Application.application.parameters.movie}" />
<mx:HBox width="100%" horizontalAlign="center">
<mx:Button label="Play" click="videoPlayer.play()" />
</mx:HBox>
</mx:VBox>
</mx:Application>
simptest.php:影片列表 + 嵌入 SWF<?php
require "DB.php";
$moviebase = 'https://localhost:8080/movies/';
$dsn = 'mysql://root@localhost/movies';
$db =& DB::connect($dsn);
if (PEAR::isError($db)) die($db->getMessage());
$source = null;
$movieId = 1;
if (array_key_exists('movie', $_GET)) $movieId = $_GET['movie'];
$movies = array();
$res = $db->query('SELECT movieId, source, title FROM movies');
while ($row = $res->fetchrow()) {
$movies[] = $row;
if ($row[0] == $movieId) $source = $row[1];
}
if ($source == null) $source = $movies[0][1];
?>
<!DOCTYPE html>
<html><body>
<table>
<tr>
<td valign="top">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="335" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="simplemovie.swf" />
<param name="quality" value="high" />
<param name="flashVars" value="movie=<?php echo $moviebase.$source ?>">
<embed src="simplemovie.swf" quality="high" width="400" height="335" play="true" loop="false" quality="high" flashVars="movie=<?php echo $moviebase.$source ?>" type="application/x-shockwave-flash" pluginspage="https://www.adobe.com/go/getflashplayer"></embed>
</object>
</td>
<td valign="top">
<?php foreach ($movies as $movie): ?>
<a href="simptest.php?movie=<?= $movie[0] ?>"><?= htmlspecialchars($movie[2]) ?></a><br/>
<?php endforeach; ?>
</td>
</tr></table>
</body></html>
simptest.php,PHP 讀取資料庫影片清單,預設播放第一部。movie=id 參數。flashVars 傳給 Flex 播放器。註:Flex/Flash 已淘汰,現代專案建議改用 HTML5 <video> + Video.js / Plyr 等播放器。