├── .babelrc ├── .dockerignore ├── .eslintignore ├── .eslintrc.js ├── .flowconfig ├── .gitignore ├── .gitlab-ci.yml ├── .npmignore ├── .prettierrc ├── .vscode └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── deploy ├── Dockerfile.dependencies ├── Dockerfile.frontci.build ├── Dockerfile.package.build ├── Dockerfile.prepare ├── Makefile ├── id_rsa └── id_rsa.pub ├── dist ├── FlussonicMsePlayer.js ├── FlussonicMsePlayer.min.js ├── FlussonicMsePlayer.min.sentry.js ├── FlussonicMsePlayer.sentry.js ├── retroview.worker.js ├── scripts │ ├── sentry.6103c0ad094caf3094f0.js │ └── sentry.984bf65be582a6792f4f.js ├── stats.worker.js └── ws.worker.js ├── gulpfile.js ├── messages.md ├── messages.ru.md ├── package.json ├── src ├── FlussonicMsePlayer.js ├── FlussonicMsePlayer.test.js ├── controllers │ ├── buffers.js │ ├── mediaSource.js │ └── ws.js ├── demo │ ├── index.html │ ├── index.js │ └── utils.js ├── enums │ ├── common.js │ ├── events.js │ ├── messages.js │ └── segments.js ├── modules │ └── MsePlayer.external.js ├── utils │ ├── get-self-scope.js │ ├── logger.js │ └── mseUtils.js └── workers │ ├── retroview.worker.js │ ├── stats.worker.js │ └── ws.worker.js ├── webpack.config.dev.js ├── webpack.config.frontci.js ├── webpack.config.js ├── webpack.config.sentry.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env"] 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread", 7 | "add-module-exports", 8 | ["transform-es2015-classes", {"loose": true}], 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /.git 2 | /node_modules 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | public/ -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | commonjs: true, 5 | es6: true, 6 | }, 7 | globals: { 8 | _gaq: false, 9 | process: false, 10 | ActiveXObject: false, 11 | VERSION: false, 12 | // Build globals 13 | __dirname: false, 14 | // Test globals 15 | after: false, 16 | afterEach: false, 17 | assert: false, 18 | before: false, 19 | beforeEach: false, 20 | describe: false, 21 | expect: false, 22 | it: false, 23 | sinon: false, 24 | xit: false, 25 | }, 26 | extends: 'eslint:recommended', 27 | parserOptions: { 28 | ecmaVersion: 9, 29 | sourceType: 'module', 30 | ecmaFeatures: { 31 | experimentalObjectRestSpread: true, 32 | spread: true, 33 | jsx: true, 34 | }, 35 | }, 36 | rules: { 37 | indent: ['error', 2, { SwitchCase: 1 }], 38 | // 'linebreak-style': ['error', 'unix'], 39 | quotes: ['error', 'single'], 40 | semi: ['error', 'always'], 41 | 'object-curly-spacing': ['error', 'always'], 42 | 'no-var': 'error', 43 | 'no-console': 2, 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/dist/.* 3 | 4 | [include] 5 | src 6 | 7 | [libs] 8 | 9 | [lints] 10 | 11 | [options] 12 | module.system.node.resolve_dirname=node_modules 13 | module.system.node.resolve_dirname=src 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | .env 4 | coverage 5 | *.cache 6 | npm-debug.log 7 | /frontci 8 | /demo 9 | 10 | # bump 11 | *.bkp 12 | 13 | # Vim 14 | *~ 15 | *.swp 16 | *.swo 17 | 18 | # PhpStorm 19 | .idea 20 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - prepare_environment 3 | - dependencies 4 | - build 5 | - deploy 6 | - distribution 7 | 8 | prepare_environment: 9 | stage: prepare_environment 10 | script: 11 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_prepare 12 | 13 | dependencies: 14 | stage: dependencies 15 | script: 16 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_dependencies 17 | dependencies: 18 | - prepare_environment 19 | 20 | build_package: 21 | stage: build 22 | script: 23 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_build_package 24 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_extract_package 25 | artifacts: 26 | paths: 27 | - dist 28 | expire_in: 1 day 29 | dependencies: 30 | - dependencies 31 | 32 | build_frontci: 33 | stage: build 34 | script: 35 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_build_frontci 36 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG ci_extract_frontci 37 | artifacts: 38 | paths: 39 | - frontci 40 | expire_in: 1 day 41 | dependencies: 42 | - dependencies 43 | 44 | deploy_review: 45 | stage: deploy 46 | dependencies: 47 | - build_frontci 48 | script: 49 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG FRONTCI_USER=$FRONTCI_USER FRONTCI_PASS=$FRONTCI_PASS ci_upload_frontci 50 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG SLACKURL=$SLACKURL ci_notify 51 | environment: 52 | name: review/$CI_COMMIT_REF_NAME 53 | url: https://front-ci.erlyvideo.ru/latest.html?p=$CI_PROJECT_NAME&r=$CI_COMMIT_REF_SLUG 54 | only: 55 | - branches 56 | except: 57 | - master 58 | 59 | deploy_staging: 60 | stage: deploy 61 | dependencies: 62 | - build_frontci 63 | script: 64 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG FRONTCI_USER=$FRONTCI_USER FRONTCI_PASS=$FRONTCI_PASS ci_upload_frontci 65 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG SLACKURL=$SLACKURL ci_notify 66 | environment: 67 | name: staging 68 | url: https://front-ci.erlyvideo.ru/latest.html?p=$CI_PROJECT_NAME&r=$CI_COMMIT_REF_SLUG 69 | only: 70 | - master 71 | 72 | publish_npm: 73 | stage: deploy 74 | script: 75 | - make -f deploy/Makefile BRANCH=$CI_COMMIT_REF_SLUG NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN ci_publish_npm 76 | only: 77 | - master 78 | 79 | deploy_live_player: 80 | stage: distribution 81 | script: 82 | - "VERSION=$(git describe --abbrev=7 --long | sed 's/^v//g')" 83 | - git clone https://gitlab-ci-token:${LIVE_PLAYER_REPO_KEY}@git.erlyvideo.ru/flussonic/live-player.git -b master --depth 3 84 | - cd live-player 85 | - git pull 86 | - jq '.peerDependencies."@flussonic\/flussonic-mse-player"="'${VERSION}'"' package.json > new.json 87 | - jq '.dependencies."@flussonic\/flussonic-mse-player"="'${VERSION}'"' new.json > package.json 88 | - git add package.json 89 | - 'git commit -m "update mse-player: ${VERSION} ${CI_COMMIT_MESSAGE}"' 90 | - git push 91 | - cd .. && rm -rf live-player/ 92 | only: 93 | - master 94 | 95 | deploy_dvr_player: 96 | stage: distribution 97 | script: 98 | - "VERSION=$(git describe --abbrev=7 --long | sed 's/^v//g')" 99 | - git clone https://gitlab-ci-token:${DVR_PLAYER_REPO_KEY}@git.erlyvideo.ru/flussonic/dvr-player.git -b master --depth 3 100 | - cd dvr-player 101 | - git pull 102 | - jq '.peerDependencies."@flussonic\/flussonic-mse-player"="'${VERSION}'"' package.json > new.json 103 | - jq '.dependencies."@flussonic\/flussonic-mse-player"="'${VERSION}'"' new.json > package.json 104 | - git add package.json 105 | - 'git commit -m "update mse-player: ${VERSION} ${CI_COMMIT_MESSAGE}"' 106 | - git push 107 | - cd .. && rm -rf dvr-player/ 108 | only: 109 | - master 110 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .* 2 | /deploy 3 | /frontci 4 | /src 5 | messages.* 6 | gulpfile.* 7 | webpack.* -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "flow", 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "bracketSpacing": true, 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "chrome", 9 | "request": "launch", 10 | "name": "Launch Chrome against localhost", 11 | "url": "http://localhost:8080", 12 | "webRoot": "${workspaceFolder}" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 18.08 2 | 3 | - incapsulation websocket, sourceBuffer logic to separate modules 4 | - onStartStalling, onEndStalling, onSeeked callbacks methods 5 | - FlussonicMsePlayer.version return current lib version 6 | - onEOS callback invoked when recordings are ended 7 | - 8 | 9 | 18.07.02 10 | 11 | - MediaInfo include active streams information 12 | - add transform-object-rest-spread babel plugin 13 | - documentation: `opts:debug`, `opts:progressUpdateTime`, `MediaInfo`, `TrackId`,. Remove/mark as deprecated `opts:bufferMode` 14 | 15 | 18.07 16 | 17 | - Switching levels(tracks) without detaching MediaSource. Now lib once create 'video' sourcebuffer and 'audio' one. And when invoke setTracks method or receive MSE_INIT_SEGMENT just flush(remove) sourcebuffers and start append new data. 18 | 19 | - Add `debug` param. If it `true` then enable logs to console 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Erlyvideo, LLC. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flussonic-mse-player 2 | 3 | flussonic-mse-player is a JavaScript library for playing video relies on flussonic backend, HTML5 video and MediaSource Extensions 4 | 5 | 6 | ## Installation 7 | 8 | ``` 9 | npm install --save @flussonic/flussonic-mse-player 10 | ``` 11 | 12 | ## Usage 13 | 14 | #### Webpack: 15 | 16 | ```javascript 17 | import FlussonicMsePlayer from '@flussonic/flussonic-mse-player' 18 | ... 19 | const player = new FlussonicMsePlayer(element, url, opts) 20 | ``` 21 | 22 | [example](https://github.com/flussonic/mse-player/tree/master/examples/simple) 23 | 24 | #### Script tag: 25 | 26 | Since the library include via script tag it is accesible at `window.FlussonicMsePlayer` 27 | 28 | ```html 29 | 30 | ``` 31 | 32 | ```javascript 33 | var FlussonicMsePlayer = window.FlussonicMsePlayer 34 | var player = new FlussonicMsePlayer(element, url, opts) 35 | ``` 36 | 37 | [example](https://github.com/flussonic/mse-player/tree/master/examples/scripttag) 38 | 39 | ### Static Methods: 40 | 41 | - **isSupported()** - return `true` if browser is supported Media Source Extension 42 | 43 | - **replaceHttpByWS(url: string)** - return new url where replaced http(s):// by ws(s):// 44 | 45 | ### Construction: 46 | 47 | ```javascript 48 | const player = new FlussonicMsePlayer(element, url, opts) 49 | ``` 50 | 51 | `element` -