You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
SubtitlesOctopus displays subtitles in .ass format and easily integrates with HTML5 videos. It supports all SSA/ASS features and fully compatible with[libass](https://github.com/libass/libass).
1
+
SubtitlesOctopus displays subtitles in .ass format and easily integrates with HTML5 videos. It supports all SSA/ASS features supported by[libass](https://github.com/libass/libass).
2
2
3
3
## Features
4
4
@@ -7,7 +7,7 @@ SubtitlesOctopus displays subtitles in .ass format and easily integrates with HT
7
7
- Works fast (because uses WebAssembly with fallback to asm.js if it's not available)
8
8
- Uses Web Workers thus video and interface doesn't lag even on "heavy" subtitles (working in background)
9
9
- Doesn't use DOM manipulations and render subtitles on single canvas
10
-
-Fully compatible with [libass](https://github.com/libass/libass)
@@ -27,7 +27,7 @@ To start using SubtitlesOctopus you only need to instantiate a new instance of
27
27
var options = {
28
28
video:document.getElementById('video'), // HTML5 video element
29
29
subUrl:'/test/test.ass', // Link to subtitles
30
-
fallbackFont:'/test/font-1.ttf', // Fallback font to be used in case none can be loaded / or has special characters
30
+
fallbackFont:'/test/font-1.ttf', // Fallback font to be used in case subtitles have special characters
31
31
fonts: ['/test/font-1.ttf', '/test/font-2.ttf'], // Links to fonts (not required, default font already included in build)
32
32
workerUrl:'/subtitles-octopus-worker.js', // Link to worker file "libassjs-worker.js"
33
33
};
@@ -47,7 +47,7 @@ the time the subtitles should render at yourself:
47
47
var options = {
48
48
canvas:document.getElementById('canvas'), // canvas element
49
49
subUrl:'/test/test.ass', // Link to subtitles
50
-
fallbackFont:'/test/font-1.ttf', // Fallback font to be used in case none can be loaded / or has special characters
50
+
fallbackFont:'/test/font-1.ttf', // Fallback font to be used in case subtitles have special characters
51
51
fonts: ['/test/font-1.ttf', '/test/font-2.ttf'], // Links to fonts
52
52
workerUrl:'/subtitles-octopus-worker.js'// Link to file "libassjs-worker.js"
53
53
};
@@ -100,7 +100,8 @@ When creating an instance of SubtitleOctopus, you can set the following options:
100
100
-`subContent`: The content of the subtitle file to play. (Require either
101
101
`subContent` or `subUrl` to be specified)
102
102
-`workerUrl`: The URL of the worker. (Default: `subtitles-octopus-worker.js`)
103
-
-`fallbackFont`: The URL of a fallback font to be used in case none can be loaded / or has special characters
103
+
-`fallbackFont`: URL to override fallback font, for example, with a CJK one. Default fallback font is Liberation Sans (Optional)
104
+
-`lazyFontLoading`: Load fonts in a lazy way. Requires Access-Control-Expose-Headers for Accept-Ranges, Content-Length, and Content-Encoding. If Content-Encoding is compressed, file will be fully fetched instead of just a HEAD request.
104
105
-`fonts`: An array of links to the fonts used in the subtitle. (Optional)
105
106
-`availableFonts`: Object with all available fonts - Key is font name in lower
106
107
case, value is link: `{"arial": "/font1.ttf"}` (Optional)
@@ -114,7 +115,7 @@ When creating an instance of SubtitleOctopus, you can set the following options:
114
115
`false`)
115
116
116
117
### Fast Render Mode (Lossy) (EXPERIMENTAL)
117
-
The Fast Render mode has been created by @no1d as a suggestion for fix browser freezing when rendering heavy subtitles (#46), it use[createImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap) to render the bitmap in the Worker, using Promises instead of direct render on canvas in the Main Thread. When the browser start to hang, it will not lock main thread, instead will run Async, so if the function createImageBitmap fail, it will not stop the rendering process at all and may cause some bitmap loss or simply will not draw anything in canvas, mostly on low end devices.
118
+
The Fast Render mode has been created by @no1d as a suggestion for fix browser freezing when rendering heavy subtitles (#46), it uses[createImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap) to render the bitmap in the Worker, using Promises instead of direct render on canvas in the Main Thread. When the browser start to hang, it will not lock main thread, instead will run Async, so if the function createImageBitmap fail, it will not stop the rendering process at all and may cause some bitmap loss or simply will not draw anything in canvas, mostly on low end devices.
118
119
119
120
**WARNING: Experimental, not stable and not working in Safari**
//Fallback for browsers not supporting fast renderMode (Safari)
6
7
self.renderMode="normal";
7
8
}
8
9
@@ -20,7 +21,8 @@ var SubtitlesOctopus = function (options) {
20
21
self.isOurCanvas=false;// (internal) we created canvas and manage it
21
22
self.video=options.video;// HTML video element (optional if canvas specified)
22
23
self.canvasParent=null;// (internal) HTML canvas parent element
23
-
self.fallbackFont=options.fallbackFont;
24
+
self.fallbackFont=options.fallbackFont||null;// Override fallback font, for example, with a CJK one. Default fallback font is Liberation Sans
25
+
self.lazyFontLoading=options.lazyFontLoading||false;// Load fonts in a lazy way. Requires Access-Control-Expose-Headers for Accept-Ranges, Content-Length, and Content-Encoding. If Content-Encoding is compressed, file will be fully fetched instead of just a HEAD request.
24
26
self.fonts=options.fonts||[];// Array with links to fonts used in sub (optional)
25
27
self.availableFonts=options.availableFonts||[];// Object with all available fonts (optional). Key is font name in lower case, value is link: {"arial": "/font1.ttf"}
26
28
self.onReadyEvent=options.onReady;// Function called when SubtitlesOctopus is ready (optional)
@@ -115,6 +117,7 @@ var SubtitlesOctopus = function (options) {
0 commit comments