Skip to content

Commit

Permalink
fix(FEC-8579): endless seeking in live stream (#4)
Browse files Browse the repository at this point in the history
Use REQUEST_PLAY and REQUEST_PAUSE events to trigger play() and pause() API on the player.
  • Loading branch information
Dan Ziv authored Oct 15, 2018
1 parent 5bedf7c commit 2db61df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 76 deletions.
74 changes: 10 additions & 64 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,25 @@
conditions: v1

sudo: required
dist: trusty
language: node_js
node_js:
- "node"

addons:
chrome: stable

cache:
yarn: true
directories:
- node_modules

before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- chmod +x ./scripts/travis.sh

script: ./scripts/travis.sh

stages:
- Tests
- Release canary
- Release
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb

jobs:
fast_finish: true
include:
# https://docs.travis-ci.com/user/build-stages/deploy-github-releases/
- stage: Release
name: "Releasing a new version"
if: tag IS present
env: TRAVIS_MODE=release
deploy:
- provider: releases
api_key:
secure: $GH_TOKEN
file_glob: true
file: dist/*
prerelease: true
skip_cleanup: true
on:
branch: master
tags: true
- provider: npm
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
on:
tags: true
branch: master
# publish canary package if on master
- stage: Release canary
if: (branch = master) AND (type != pull_request) AND commit_message !~ /^chore\(release\)/
env: TRAVIS_MODE=releaseCanary
deploy:
provider: npm
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
tag: canary
on:
tags: false
branch: master
# Required tests
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running lint"
env: TRAVIS_MODE=lint
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running Flow type check"
env: TRAVIS_MODE=flow
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running unit tests"
env: TRAVIS_MODE=unitTests
script:
- npm run eslint
- npm run flow
- npm run test
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"watch": "webpack --progress --colors --watch",
"test": "NODE_ENV=test karma start --color",
"release": "standard-version",
"pushTaggedRelease": "git push --follow-tags --no-verify origin master",
"publish": "git push --follow-tags --no-verify origin master",
"eslint": "eslint . --color",
"flow": "flow check",
"precommit": "lint-staged"
"precommit": "lint-staged",
"commit:dist": "git add --force --all dist && (git commit -m 'chore: update dist' || exit 0)"
},
"lint-staged": {
"*.{js,jsx}": [
Expand Down
18 changes: 8 additions & 10 deletions src/receiver-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class ReceiverManager {
[cast.framework.messages.MessageType.STOP]: this.onStop
};
_playerManagerEventHandlers: {[event: string]: Function} = {
[cast.framework.events.EventType.PLAY]: this._onPlayEvent,
[cast.framework.events.EventType.PAUSE]: this._onPauseEvent,
[cast.framework.events.EventType.REQUEST_PLAY]: this._onPlayEvent,
[cast.framework.events.EventType.REQUEST_PAUSE]: this._onPauseEvent,
[cast.framework.events.EventType.PLAYER_LOAD_COMPLETE]: this._onPlayerLoadCompleteEvent
};
_castContextEventHandlers: {[event: string]: Function} = {
Expand Down Expand Up @@ -129,7 +129,7 @@ class ReceiverManager {
_onSourceSelected(event: FakeEvent, loadRequestData: Object, resolve: Function): void {
const source = event.payload.selectedSource[0];
this._handleAutoPlay(loadRequestData);
this._handleLive(loadRequestData);
this._handleLiveDvr(loadRequestData);
this._setMediaInfo(loadRequestData, source);
this._maybeSetDrmLicenseUrl(source);
resolve(loadRequestData);
Expand All @@ -155,12 +155,10 @@ class ReceiverManager {
}
}

_handleLive(loadRequestData: Object): void {
if (this._player.isLive()) {
if (!this._player.isDvr() || loadRequestData.currentTime === LIVE_EDGE) {
this._shouldSeekToLiveEdge = true;
}
this._logger.debug(`Live will seek to live edge? ${this._shouldSeekToLiveEdge}`);
_handleLiveDvr(loadRequestData: Object): void {
if (this._player.isDvr() && loadRequestData.currentTime === LIVE_EDGE) {
this._shouldSeekToLiveEdge = true;
this._logger.debug(`Live DVR will seek to live edge? ${this._shouldSeekToLiveEdge}`);
}
}

Expand All @@ -180,7 +178,7 @@ class ReceiverManager {

_onPlayEvent(): void {
if (this._firstPlay) {
if (this._player.isLive() && this._shouldSeekToLiveEdge) {
if (this._shouldSeekToLiveEdge) {
this._player.seekToLiveEdge();
}
if (!this._shouldAutoPlay) {
Expand Down

0 comments on commit 2db61df

Please sign in to comment.