cancel
Showing results for 
Search instead for 
Did you mean: 

Open default video player from unity App

alexey_suvorov
Honored Guest

Hello.

I don’t understand how to open a video in a standard video player in Oculus Quest 3 from a script. I'm trying to open it in three ways, none of them work.

The first two methods work on PC without any problem.

Method3 from this plugin: https://github.com/Andy-Roger/UnityAndroidNativeFileOpener

video: https://youtu.be/Qtk5pgVpxLc

C# code: 

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEngine;


public class VideoOpener : MonoBehaviour
{
    public void OpenVideo1()
    {
        try
        {
            Application.OpenURL(Application.persistentDataPath + "/DroneAttack_360_TB_30sec.mp4");
        }
        catch (Exception ex) { UnityEngine.Debug.LogError(ex); }
    }

    public void OpenVideo2()
    {
        try
        {
            string pathTo = (Application.persistentDataPath + "/DroneAttack_360_TB_30sec.mp4");
            Process process = Process.Start(pathTo);
            process.WaitForExit();
            process.Close();
        }
        catch (Exception ex) { UnityEngine.Debug.LogError(ex); }
    }

    public void OpenVideo3()
    {
        try
        {
            AndroidContentOpenerWrapper.OpenContent(Application.persistentDataPath + "/DroneAttack_360_TB_30sec.mp4");
        }
        catch (Exception ex)
        {
            UnityEngine.Debug.LogError(ex);
        }
    }

    public void OpenGoogle()
    {
        Application.OpenURL("https://www.google.com/");
    }
}

Manifest: 

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.unity3d.player"
    xmlns:tools="http://schemas.android.com/tools">
	<uses-permission android:name="android.permission.RECORD_AUDIO"/>
	<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
	<uses-feature android:name="android.hardware.microphone" android:required="false"/>
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
	
    <application android:requestLegacyExternalStorage="true">
		<provider
  android:name="com.cartoontexas.andyr.unityplugin.UnitySSContentProvider"
  android:authorities="a_very_unique_name"
  android:exported="false"
  android:grantUriPermissions="true" />
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
				  android:grantUriPermissions="true"
                  android:theme="@style/UnityThemeSelector">
			<intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
    </application>
</manifest>

 

 

1 REPLY 1

alexey_suvorov
Honored Guest

 

 

Ok. I Use this asset: https://assetstore.unity.com/packages/tools/integration/native-android-toolkit-mt-webview-scheduled-...

and this code work perfect on android. 

But in quest3, just black screen and game crash. 

public class Test : MonoBehaviour
{
    private void Awake()
    {
        if (NativeAndroidToolkit.isInitialized == false)
            NativeAndroidToolkit.Initialize();
    }

    private void Start()
    {
        //NAT.Dialogs.ShowSimpleAlertDialog("Simple Alert Dialog", "This is a simple alert dialog.", true);
        new NAT.Permissions.PermissionRequester()
          .addPermissionToRequest(NAT.Permissions.AndroidPermission.AccessFilesAndMedia)
          .RequestThisPermissions();

        StartCoroutine(startafter());
    }

    public IEnumerator startafter()
    {
        yield return new WaitForSeconds(3);
        NAT.Files.OpenWithDefaultApplication(NAT.Files.Scope.Movies, "test", "video.mp4");
    }
}