viromedia / virocore

ViroCore cross-platform AR/VR renderer
MIT License
370 stars 108 forks source link

360 video paused in portal for release 1.13 #251

Open YudizSumeet opened 5 years ago

YudizSumeet commented 5 years ago

Video is a still image when I use latest version (1.13) of SDK while the same code works for previous version (1.0).

Uri parse = Uri.parse("file:///android_asset/video.mp4");
VideoTexture videoTexture = new VideoTexture(mViroView.getViroContext(), parse);
videoTexture.setLoop(true);
videoTexture.play();
portalScene.setBackgroundTexture(videoTexture);
dam00n commented 5 years ago

The latest version of virocore is 1.13, please make sure to follow the upgrade instructions listed in the release notes -> https://virocore.viromedia.com/docs/releases

YudizSumeet commented 5 years ago

Hi @dam00n , thanks for the quick reply. First of all, apologies for the version error in my question. I actually meant 1.13 and not 1.3. I tried updating GVR version to 1.18 as mentioned in upgrade instructions and my app is already configured on API 28. I'm still facing the same issue. Here is a screen-recording and the code for better understanding of the issue. I use the same code to load video in both the scenarios.

Video : https://www.dropbox.com/s/kebf5cu8s0t5hkk/virocore_video_issue.mov?dl=0

Code :

package com.example.virosample;

import android.app.Activity;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.viro.core.ARAnchor;
import com.viro.core.ARNode;
import com.viro.core.ARScene;
import com.viro.core.Object3D;
import com.viro.core.OmniLight;
import com.viro.core.Portal;
import com.viro.core.PortalScene;
import com.viro.core.Vector;
import com.viro.core.VideoTexture;
import com.viro.core.ViroView;
import com.viro.core.ViroViewARCore;

import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;

public class ViroActivity extends Activity {
    private static final String TAG = ViroActivity.class.getSimpleName();

    private ViroView mViroView;

    private ARScene mScene;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mViroView = new ViroViewARCore(this, new ViroViewARCore.StartupListener() {
            @Override
            public void onSuccess() {
                displayScene();
            }

            @Override
            public void onFailure(ViroViewARCore.StartupError error, String errorMessage) {
                Log.e(TAG, "Error initializing AR [" + errorMessage + "]");
            }
        });

        setContentView(mViroView);
    }

    private void displayScene() {
        mScene = new ARScene();
        mScene.setListener(new ARSceneListener(this, mViroView));

        //add light
        OmniLight light = new OmniLight();
        light.setColor(Color.WHITE);
        light.setPosition(new Vector(0, 1, -4));
        mScene.getRootNode().addLight(light);

        //load ship window model
        Object3D shipDoorModel = new Object3D();
        shipDoorModel.loadModel(mViroView.getViroContext(), Uri.parse("file:///android_asset/portal_ship.vrx"), Object3D.Type.FBX, null);

        //create a portal
        Portal portal = new Portal();
        portal.addChildNode(shipDoorModel);
        portal.setScale(new Vector(5, 5, 5));
        portal.setPosition(new Vector(0, -3, 0));

        PortalScene portalScene = new PortalScene();
        portalScene.setPosition(new Vector(0, 0, -5));
        portalScene.setPassable(true);
        portalScene.setPortalEntrance(portal);

        Uri parse = Uri.parse("file:///android_asset/video.mp4");
        VideoTexture videoTexture = new VideoTexture(mViroView.getViroContext(), parse);
        videoTexture.play();
        videoTexture.setLoop(true);
        portalScene.setBackgroundTexture(videoTexture);

        mScene.getRootNode().addChildNode(portalScene);

        //set scene in ViroView
        mViroView.setScene(mScene);

        View.inflate(this, R.layout.viro_initializing_ar, ((ViewGroup) mViroView));
    }

    private static class ARSceneListener implements ARScene.Listener {
        private WeakReference<Activity> mCurrentActivityWeak;
        private boolean mInitialized;

        public ARSceneListener(Activity activity, View rootView) {
            mCurrentActivityWeak = new WeakReference<Activity>(activity);
            mInitialized = false;
        }

        @Override
        public void onTrackingUpdated(ARScene.TrackingState trackingState,
                                      ARScene.TrackingStateReason trackingStateReason) {
            if (!mInitialized && trackingState == ARScene.TrackingState.NORMAL) {
                Activity activity = mCurrentActivityWeak.get();
                if (activity == null) {
                    return;
                }

                TextView initText = (TextView) activity.findViewById(R.id.initText);
                initText.setText("AR is initialized");
                mInitialized = true;
            }
        }

        @Override
        public void onAmbientLightUpdate(float v, Vector vector) {

        }

        @Override
        public void onTrackingInitialized() {
            // This method is deprecated.
        }

        @Override
        public void onAnchorFound(ARAnchor arAnchor, ARNode arNode) {

        }

        @Override
        public void onAnchorRemoved(ARAnchor arAnchor, ARNode arNode) {

        }

        @Override
        public void onAnchorUpdated(ARAnchor arAnchor, ARNode arNode) {

        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        mViroView.onActivityStarted(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mViroView.onActivityResumed(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mViroView.onActivityPaused(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        mViroView.onActivityStopped(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mViroView.onActivityDestroyed(this);
    }
}
VikAdvani commented 5 years ago

Hi @YudizSumeet, thanks for reporting this. I've confirmed this is a bug and we will fix it in our next release.

VikAdvani commented 5 years ago

Hi @YudizSumeet, we have fixed this bug and it will be included in Virocore 1.14 :)

YudizSumeet commented 5 years ago

@VikAdvani Thanks a lot! Awaiting 1.14 version :)

YudizSumeet commented 5 years ago

@VikAdvani Any update on release(1.14) that solves this issue?