-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### Description of the Changes part of the Advanced Timeline feature. this PR contains changes and new code for supporting segments on the seekbar, whenever there are chapters. - extracting the progress & buffered element to a new comp named ProgressBar - add new state `segments` to seekbar - add new actions for updating the segments **related PR-** kaltura/playkit-js-timeline#11 Solves FEC-13114 ### CheckLists - [x] changes have been done against master branch, and PR does not conflict - [ ] new unit / functional tests have been added (whenever applicable) - [ ] test are passing in local environment - [ ] Travis tests are passing (or test results are not worse than on master branch :)) - [ ] Docs have been updated
- Loading branch information
1 parent
5fdc0df
commit 5519099
Showing
7 changed files
with
149 additions
and
52 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/components/progress-indicator/_progress-indicator.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.player .seek-bar { | ||
&.ad-break { | ||
cursor: initial; | ||
|
||
.progress-bar .progress { | ||
background-color: $ads-color; | ||
} | ||
} | ||
|
||
&.live { | ||
.progress-bar .progress { | ||
background-color: $live-color; | ||
} | ||
} | ||
|
||
.progress-bar { | ||
.progress { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
border-radius: inherit; | ||
background-color: $primary-color; | ||
} | ||
.buffered { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
border-radius: inherit; | ||
background-color: rgba(255, 255, 255, 0.3); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {ProgressIndicator} from './progress-indicator'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//@flow | ||
import {h, Fragment, Component} from 'preact'; | ||
import style from '../../styles/style.scss'; | ||
import {connect} from 'react-redux'; | ||
import {withPlayer} from '../player'; | ||
|
||
/** | ||
* mapping state to props | ||
* @param {*} state - redux store state | ||
* @returns {Object} - mapped state to this component | ||
*/ | ||
const mapStateToProps = state => ({ | ||
dataLoaded: state.engine.dataLoaded, | ||
currentTime: state.seekbar.currentTime, | ||
duration: state.engine.duration, | ||
isMobile: state.shell.isMobile, | ||
adBreak: state.engine.adBreak | ||
}); | ||
|
||
/** | ||
* ProgressBar component | ||
* | ||
* @class ProgressIndicator | ||
* @extends {Component} | ||
*/ | ||
@connect(mapStateToProps) | ||
@withPlayer | ||
class ProgressIndicator extends Component { | ||
/** | ||
* get current buffered percent from the player | ||
* | ||
* @returns {number} - current buffered percent | ||
* @memberof ProgressIndicator | ||
*/ | ||
getBufferedPercent(): number { | ||
const {player} = this.props; | ||
if (this.props.duration > 0 && player.buffered.length > 0) { | ||
const buffered = player.isLive() ? player.buffered.end(0) - player.getStartTimeOfDvrWindow() : player.buffered.end(0); | ||
const bufferedPercent = (buffered / this.props.duration) * 100; | ||
return bufferedPercent < 100 ? bufferedPercent : 100; | ||
} | ||
return 0; | ||
} | ||
|
||
/** | ||
* render component | ||
* | ||
* @param {*} props - component props | ||
* @returns {React$Element} - component | ||
* @memberof ProgressIndicator | ||
*/ | ||
render(props: any): React$Element<any> { | ||
const bufferedWidth = `${Math.round(this.getBufferedPercent())}%`; | ||
const progressWidth = `${props.player.isLive() && props.player.isOnLiveEdge() ? 100 : (props.currentTime / props.duration) * 100}%`; | ||
return ( | ||
<Fragment> | ||
<div className={style.buffered} style={{width: bufferedWidth}} /> | ||
{props.dataLoaded ? <div className={style.progress} style={{width: progressWidth}} /> : undefined} | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
ProgressIndicator.displayName = 'ProgressIndicator'; | ||
export {ProgressIndicator}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters