SOURCE URL: https://flowplayer.org/docs/subtitles.html

Setting up

Subtitles are loaded with a <track> element as follows

<div class="flowplayer">
<video>
<source type="video/webm" src="http://mydomain.com/my-video.webm">
<source type="video/mp4" src="http://mydomain.com/my-video.mp4">
<source type="video/ogg" src="http://mydomain.com/my-video.ogv">
 
<!-- the track element -->
<track src="/path/to/my-subtitles-en.vtt">
 
</video>
</div>

The WEBVTT file of the track element has the following structure:

WEBVTT FILE
 
1
00:00:01.000 --> 00:00:04.000
The first subtitle from 1 seconds to 4 seconds
This is a second line
And a third one
 
2
00:00:05.000 --> 00:00:06.000
<b>Bold</b>, <i>italic</i> and <u>underlines</u> are supported
 
...

A sample file. Understanding the VTT file format.

Note: Subtitles must be loaded from a local path - unless they are served with a loose cross-origin policy with an appropriate Access-Control-Allow-Origin header. For instance, in an Apache configuration:

Header set Access-Control-Allow-Origin "*"

For more details look up cross-orgin resource sharing.

Custom looks

The first subtitle above would be rendered on the player as follows

<div class='fp-subtitle'>
<p>The first subtitle from 1 seconds to 4 seconds</p><br>
<p>This is a second line</p><br>
<p>And a third one</p><br>
</div>

Flowplayer comes with a default look for the subtitles but here is how you can alter the looks with CSS

/ override default looks /
.flowplayer .fp-subtitle {
font-size: 18px;
}
 
/ visible subtitle looks (.fp-active class) /
.flowplayer .fp-subtitle.fp-active { 
opacity: 0.8;
}
 
/ custom looks for 7:th subtitle /
.flowplayer.cue6 .fp-subtitle p {
font-size: 40px;
}

Native subtitles

Currently the <track> element is supported natively in following browsers

  • IE 10 (since November 2011)
  • Google Chrome 18 (since November 2011)
  • Safari 6 (July 2012)
  • Opera 12.5 (August 2012)

You can enable native support with nativesubtitles configuration variable and by adding default attribute to your track element. For example

<div class="flowplayer" data-nativesubtitles="true">
<video>
<source type="video/webm" src="http://mydomain.com/my-video.webm">
<source type="video/mp4" src="http://mydomain.com/my-video.mp4">
<track src="/path/to/my-subtitles-en.vtt" default>
</video>
</div>

After this subtitle looks are browser dependent and you lose the CSS customization possibilities. Native support is present when flowplayer.support.subtitles is true. For example

if (flowplayer.support.subtitles) {
// do your thing
}

JavaScript API

Internally flowplayer uses cuepoints to notify when subtitle starts and ends. Here is an example of how to capture subtitle events

player.bind("cuepoint", function(e, api, cuepoint) {
 
var subtitle = cue.subtitle;
 
// start a subtitle
if (subtitle) {
 
}
 
// end the subtitle
if (cuepoint.subtitleEnd) {
 
}
 
});

The subtitle object has following properties title, startTime, endTime and text. An API property subtitles is an array of all subtitles. For example

console.info(flowplayer().subtitles);

Known issues and limitations

Flowplayer does not add any UI element for controlling subtitles. If the <track> element is provided subtitles are enabled and cannot be removed by the user. You also need to control the language of the subtitles on your web application. User cannot switch the language from the player.

Flowplayer does not support VTT extra definitions such as text alignment and line position. Style is completely controlled with CSS for full cross browser support.

When using the default attribute on the track element some browsers may show their native controlbar for a short glimpse of time.

Currently subtitles are not supported in playlists and are omitted when the player is embedded.

Flowplayer-Subtitle的更多相关文章

  1. HTML5播放器FlowPlayer的极简风格效果

    在线演示 本地下载 使用Flowplayer生成的极简风格的播放器效果.

  2. [开发笔记]-flowplayer视频播放插件

    最近项目中需要添加播放视频的功能,视频文件是flv格式的.在网上找了一些jQuery视频播放插件,还是觉得“flowplayer”要好一些.特将使用方法记录一下. flowplayer也有html5版 ...

  3. 根据body的内容 查找h2标签的@class="subtitle"的值

    <pre name="code" class="html"><body class="api jquery listing" ...

  4. flowplayer+flashhls使用过程中发现的一些小问题

    flashls里边有好几套代码,主要看生成路径,其中flowplayer用了flashls.swc,flashls.swc使用的代码在这里:/src/org/mangui/hls,所以要注意,当搜索代 ...

  5. FlowPlayer 参数说明

    <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> & ...

  6. 兼容各个浏览器的H.264播放: H.264+HTML5+FLOWPLAYER+WOWZA+RMTP

    一.方案确定 计划做视频播放,要求可以播放H264编码的mp4文件,各个浏览器,各种终端都能播放. 首先查找可行性方案, http://www.cnblogs.com/sink_cup/archive ...

  7. flowplayer视频播放插件

    flowplayer视频播放插件 最近项目中需要添加播放视频的功能,视频文件是flv格式的.在网上找了一些jQuery视频播放插件,还是觉得“flowplayer”要好一些.特将使用方法记录一下. f ...

  8. E/MediaPlayer: Should have subtitle controller already set

    原文链接:http://stackoverflow.com/questions/20087804/should-have-subtitle-controller-already-set-mediapl ...

  9. FFmpeg中subtitle demuxer实现

    [时间:2019-01] [状态:Open] [关键词:字幕,ffmpeg,subtitle,demuxer,源码] 0 引言 本文重心在于FFmpeg中subtitle demuxer的实现逻辑. ...

  10. 谷歌机翻英文字幕输出(Subtitle Edit)

    Subtitle Edit 下载地址(https://github.com/SubtitleEdit/subtitleedit/releases/tag/3.5.0) 添加字幕文件后,点下图的Auto ...

随机推荐

  1. c#中文转全拼或首拼

    参考:http://www.jb51.net/article/42217.htmhttp://blog.csdn.net/cstester/article/details/4758172 Chines ...

  2. Oracle常用命令(持续更新)

    --1.解锁用户 alter user 用户名 account unlock; --2.开启最小补充日志记录(执行的DML操作会被记录下来)  alter database add supplemen ...

  3. Mysql event学习

    我们可能比较熟悉crond,但是mysql也有一个自己的叫event,oracle的叫job. 开启mysql的event有很多种方法,和临时开启.我们在配置文件里面添加参数,随着服务一起开启. 在[ ...

  4. NY-字符串替换

    描述编写一个程序实现将字符串中的所有"you"替换成"we" 输入 输入包含多行数据 每行数据是一个字符串,长度不超过1000 数据以EOF结束 输出 对于输入 ...

  5. C# Datatable排序

    在C#中要对Datatable排序,可使用DefaultView的Sort方法.先获取Datatable的DefaultView,然后设置 得到的Dataview的sort属性,最后用视图的ToTab ...

  6. java跳出外部循环

    java跳出外部循环两种方法 //用flag标识 boolean flag = true; for(int i=0;i<10&&flag;i++){ for(int j=0;j& ...

  7. ios-高德、百度后台定位并上传服务器

    一.配置高德或百度的后台定位框架和代码(略). 二.配置app不被系统kill,定时获取地理位置信息,并上传服务器(AppDelegate里面). 具体代码: 1. - (void)applicati ...

  8. Wordpress本地伪静态设置

    遇到的问题: 在主题的目录页,用wordpress默认链接方式是的,但是改了固定链接结构为:/%post_id%.html后,就访问不了了,开始以为是我主题的问题,然后切换为官方主题也是访问不了,而神 ...

  9. 纯CSS实现tooltip提示框,CSS箭头及形状之续篇--给整个tooltip提示框加个边框

    在前面一篇中我们介绍了纯CSS实现tooltip提示框,通俗的讲也就是CSS箭头及形状 不过注意一点是,他始终是一个元素,只是通过CSS实现的,今天我们要说的是给这个“tooltip提示框”整体加一个 ...

  10. MySQL 的 utf8_general_ci 和 utf8_unicode_ci 有什么区别,应如何选择?

    一般的解说是 utf8_general_ci 速度较快,utf8_unicode_ci 准确性较好 … 但快在那里,又好在什么地方呢? 首先就其准确性说,这世界上有无数种文字,除了通用的英文使用我们较 ...