googlevr / gvr-android-sdk

Google VR SDK for Android
http://developers.google.com/vr/android/
Other
3.28k stars 1.28k forks source link

How to interact with the MediaPlayer, using video360 project ? #620

Closed KeySeeDev closed 5 years ago

KeySeeDev commented 5 years ago

Hi, i trying to implement some basic media player functions on top of the vr360 project but i cant make it work. I tried to add inside a custom function to begin with but the media player seems unvailable... How to bind it? Thanks for any help.

public class VrVideoActivity extends GvrActivity {
   ...
   public void myPause() {
        this.onPause();
    }
}

PS. I'm preparing a mini-project repo if maybe someone fancies to try.

sigmaxipi commented 5 years ago

See https://github.com/googlevr/gvr-android-sdk/blob/master/samples/sdk-video360/src/main/java/com/google/vr/sdk/samples/video360/VideoUiView.java#L157 is the code that handles the UI for 2D & VR mode.

KeySeeDev commented 5 years ago

Thanks you for the help. Yep, i tried to look at that code and tried adding

public void myPause() {
        try {
            mediaLoader.pause();
        } catch (Exception e) { Log.d(TAG, "Error while trying mediaLoader.pause();");  };

       try {
            mediaLoader.mediaPlayer.pause();
        } catch (Exception e) { Log.d(TAG, "Error while trying mediaLoader.mediaPlayer.pause();"); };

       try {
            (new MediaLoader(this)).mediaPlayer.pause();
        } catch (Exception e) { Log.d(TAG, "Error while trying mediaLoader.pause();"); };
    }

and to run that function I'm using (new VrVideoActivity()).myPause(); If you need more info you can find the repo here: https://github.com/StarStep/cordova-vr-help GVR: cordova-vr-help/platforms/android/app/src/main/java/com/thevrplugin/cordovapluginvrplayer/

KeySeeDev commented 5 years ago

Finally got it to work by declaring as static the MediaLoader public static MediaLoader mediaLoader; and then I were able to interact with the player like so

public static void myPause() {
    mediaLoader.mediaPlayer.pause();
}