Skip to content

Commit

Permalink
trying to fix seekbar and buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
souporserious committed Aug 10, 2015
1 parent 538a2ad commit 25ee20d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ React media container component to help build video & audio players.

- [x] Fix Progress component
- [x] Fix Volume getting locked up when player is muted
- [] SeekBar crashes Safari
- [] Playlist feature
- [] Show time preview when hovering scrubber
- [] Show thumbnail preview when hovering scrubber
Expand Down
3 changes: 2 additions & 1 deletion example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import './main.scss';
// http://shapeshed.com/examples/HTML5-video-element/video/320x240.m4v
// http://html5demos.com/assets/dizzy.mp4
// http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
// https://vid4u.org/ninja/5/dev/assets/madmax-intro.mp4

class App extends Component {

Expand All @@ -33,7 +34,7 @@ class App extends Component {
{props => {

const { player, playing, duration, current, progress, muted, volume, fullscreen } = props;

return(
<div className="media__container">
<div
Expand Down
10 changes: 5 additions & 5 deletions src/MediaContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class MediaContainer extends Component {

player.addEventListener('loadedmetadata', ::this._handleLoadedMetaData);

player.addEventListener('loadeddata', () =>
// make sure video is ready before trying to check buffer progress
player.addEventListener('progress', ::this._handleProgress)
);
// player.addEventListener('loadeddata', () =>
// // make sure video is ready before trying to check buffer progress
// player.addEventListener('progress', ::this._handleProgress)
// );

player.addEventListener('timeupdate', ::this._handleTimeUpdate);

Expand Down Expand Up @@ -148,7 +148,7 @@ class MediaContainer extends Component {

this.setState({
duration: duration,
progress: buffered.end(0) / duration
//progress: buffered.end(0) / duration
});
}

Expand Down
25 changes: 6 additions & 19 deletions src/controls/SeekBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,17 @@ import React, { Component } from 'react';

class SeekBar extends Component {

dragging = false

_handleChange(e) {
const { player } = this.props;
player.currentTime = +e.target.value;
}

_handleDragging() {
this.dragging = true;
_handleMouseDown() {
this.props.player.pause();
}

_handleDrag(e) {

const { player } = this.props;

if(this.dragging) {

player.currentTime = +e.target.value;

if(e.type === 'mouseup') {
this.dragging = false;
}
}
_handleMouseUp() {
this.props.player.play();
}

render() {
Expand All @@ -35,9 +23,8 @@ class SeekBar extends Component {
max={(this.props.duration).toFixed(4)}
value={this.props.current}
onChange={::this._handleChange}
onMouseDown={::this._handleDragging}
onMouseMove={::this._handleDrag}
onMouseUp={::this._handleDrag}
onMouseDown={::this._handleMouseDown}
onMouseUp={::this._handleMouseUp}
/>
);
}
Expand Down

0 comments on commit 25ee20d

Please sign in to comment.