viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

Close Button Causes Video Turn Black When Sound Continues to Play #641

Open tuananhcwrs opened 5 years ago

tuananhcwrs commented 5 years ago

Description

Hello (@dthian )

When I use native google vr player, and it is in Vr mode, the close button is used to switch back to mono mode (in react-viro, we have to set vrModeEnabled: false )

So to mimic the above behavior in my app using ViroVRSceneNavigator, I listen to onExitViro event (happen when users click on close button) to set vrModeEnabled: false.

Actual result is that the video turns black and sound keep on playing.

Reproducible Demo

Here is my demo code

The ViroSampleSceneNavigator.js

var ViroSampleSceneNavigator = createReactClass({
  render: function() {
    return (
      <ViroVRSceneNavigator
        initialScene={{
          scene: vrScenes['ViroMediaPlayer'],
        }}
        vrModeEnabled={this.props.vrModeEnabled}
        onExitViro={this.props.onExitVrMode}
        apiKey={apiKey} />
    );
  },
});

module.exports = ViroSampleSceneNavigator;

I make sure that I have the "ViroMediaPlayer" scene, just no need to put it here.

And then in the App.js

import React, { Component } from 'react';
import { View, Text } from 'react-native';
import ViroSampleSceneNavigator from './ViroSampleSceneNavigator';

var createReactClass = require('create-react-class');

var App = createReactClass({
  getInitialState() {
    return {
      vrModeEnabled: true
    }
  },

  render: function() {
    return (
      <View style={{ flex: 1 }}>
        <View style={{ flex: 1 }}>
          <ViroSampleSceneNavigator {... 
            { 
              vrModeEnabled: this.state.vrModeEnabled,
              onExitVrMode: this._onExitVrMode
            }}/>
        </View>
        <View style={{ flex: 1, backgroundColor: 'skyblue'}} />
      </View>
    );
  },

  _onExitVrMode() {
    this.setState(
      { vrModeEnabled: false }
    );
  }
});

module.exports = App;

Please help.

tuananhcwrs commented 5 years ago

Hello Any one can support? @dam00n could you please?

Actuallly, I need to enable/disable VR mode while still keeps video playing. That is my goal. Thanks!

dthian commented 5 years ago

Hey @tuananhcwrs, with ViroReact, you can't switch directly from Mono to VR mode - i think you might have to re-create the ViroSampleSceneNavigator with the new mode. Hope that helps!

tuananhcwrs commented 5 years ago

Hello @dthian ,

Thank for your reply. My goal is that I need to keep video playing while switching between mono and vr mode. Using a different Navigator does not help me to keep video continue playing. Or I miss something?

If there is no way to work around, then I have to accept that it is a limitation. Thanks.