Add video.play() after each rerender (Android Chrome Fix)

This commit is contained in:
Jerko Steiner 2016-04-01 15:29:12 -04:00 committed by Jerko Steiner
parent ef07001f22
commit 1cdb662b28
4 changed files with 24 additions and 1 deletions

View File

@ -15,7 +15,8 @@ function app() {
let videos = _.map(streams, (stream, userId) => { let videos = _.map(streams, (stream, userId) => {
let url = createObjectURL(stream); let url = createObjectURL(stream);
function markActive() { function markActive(event) {
event.target.play();
if (activeStore.isActive(userId)) return; if (activeStore.isActive(userId)) return;
dispatcher.dispatch({ dispatcher.dispatch({
type: 'mark-active', type: 'mark-active',

View File

@ -14,10 +14,23 @@ const handshake = require('./peer/handshake.js');
const socket = require('./socket.js'); const socket = require('./socket.js');
const streamStore = require('./store/streamStore.js'); const streamStore = require('./store/streamStore.js');
function play() {
let videos = window.document.querySelectorAll('video');
Array.prototype.forEach.call(videos, (video, index) => {
debug('playing video: %s', index);
video.play();
});
}
function render() { function render() {
ReactDom.render(<App />, document.querySelector('#container')); ReactDom.render(<App />, document.querySelector('#container'));
play();
} }
dispatcher.register(action => {
if (action.type === 'play') play();
});
streamStore.addListener(() => () => { streamStore.addListener(() => () => {
debug('streamStore - change'); debug('streamStore - change');
debug(streamStore.getStreams()); debug(streamStore.getStreams());

View File

@ -39,6 +39,7 @@ function init(socket, roomName, stream) {
peer.once('connect', () => { peer.once('connect', () => {
debug('peer: %s, connect', user.id); debug('peer: %s, connect', user.id);
dispatcher.dispatch({ type: 'play' });
}); });
peer.on('stream', stream => { peer.on('stream', stream => {

View File

@ -100,6 +100,9 @@ body {
text-align: right; text-align: right;
.video-container { .video-container {
background-color: black;
box-shadow: 0px 0px 5px #333;
border-radius: 30px;
display: inline-block; display: inline-block;
margin-right: 10px; margin-right: 10px;
width: 150px; width: 150px;
@ -107,6 +110,7 @@ body {
z-index: 2; z-index: 2;
video { video {
border-radius: 30px;
pointer: cursor; pointer: cursor;
object-fit: cover; object-fit: cover;
width: 100%; width: 100%;
@ -115,6 +119,9 @@ body {
} }
.video-container.active { .video-container.active {
background-color: transparent;
box-shadow: none;
border-radius: 0;
position: fixed; position: fixed;
width: 100%; width: 100%;
left: 0; left: 0;
@ -124,6 +131,7 @@ body {
z-index: -1; z-index: -1;
video { video {
border-radius: 0;
pointer: inherit; pointer: inherit;
} }
} }