0

我使用的 wordpress 主题内置在 jwplayer8 中。在帮助下,我能够让播放器工作并播放 HLS 视频。现在我希望让 .ASS 字幕正常工作。我找到了 SubtitlesOctopus,似乎所有示例代码都有预先定义和标记的字幕轨道。并非我所有的视频都仅限于 1-2 个字幕轨道。我希望找到一种方法让它从 index.m3u8 中提取字幕,就像 webvtt 字幕的默认设置一样。或者,如果有办法让它搜索目录并使用文件名作为标签。

这是我当前的播放器脚本

<?php 
$episode_pagi = DDbmoviesHelpers::EpisodeNav($tmdbids,$temporad,$episode);
$next_episode = doo_isset($episode_pagi,'next');
$link_next = !empty($next_episode) ? 'href="'.$next_episode['permalink'].'" title="'.$next_episode['title'].'"' : 'href="#" class="nonex"';

?>
<!DOCTYPE html>
<html lang="en" dir="ltr" data-cast-api-enabled="true">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noindex">
        <title>JW Player</title>
        <script src='https://ssl.p.jwpcdn.com/player/v/8.6.2/jwplayer.js'></script>
        <script type="text/javascript">jwplayer.key="<?php echo $jw8key; ?>";</script>
        <script type="text/javascript">
            var jw = <?php echo json_encode($data)."\n"; ?>
        </script>
        <style type="text/css" media="all">
            html,body{padding:0;margin:0;height:100%}
            #player{width:100%!important;height:100%!important;overflow:hidden;background-color:#000}
        </style>
    </head>
    <body class="jwplayer">
        <div id="player"></div>
        <script type="text/javascript">
            const defaulGateway = "https://gateway.anime4all.net/ipfs/";
            let gateway;
            if(sessionStorage.getItem("ipfsGateway")) {
                gateway = sessionStorage.getItem("ipfsGateway");
            } else {
                gateway = defaulGateway;
            }
            const player = jwplayer('player').setup({
                image: jw.image,
                mute: false,
                volume: 100,
                autostart: jw.auto,
                repeat: false,
                abouttext: jw.text,
                aboutlink: jw.link,
                skin: {
                    active: jw.color
                },
                logo: {
                    file: jw.logo,
                    hide: true,
                    link: jw.link,
                    margin: '15',
                    position: jw.lposi
                },
                sources: [{
                    file: gateway + "<?php echo $_GET['source'].'/index.m3u8'; ?>",
                    type: 'video/mp4'
                }],
                "cast": {}
            })
            player.on("complete", () => {
                console.log("video completed" + "<?php echo $next_episode; ?>");
                window.parent.eval(() => {
                    window.parent.location.href = window.parent.nextEpisode;
                })()
            })
        </script>
    </body>
</html>

https://github.com/libass/JavascriptSubtitlesOctopus https://www.jwplayer.com/html5-video-player/

4

0 回答 0