using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
using System.IO;
using System.Text;
using System;
using System.Xml;
public class NewBehaviourScript : MonoBehaviour
{
public static NewBehaviourScript Instance;
private void Awake()
{
Instance = this;
}
//调起pico android播放器并播放指定视频
public void StartPlayer( string fileName,string pathName)
{
pathName += ".mp4";
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject context = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent", "picovr.intent.action.player");
intent.Call<AndroidJavaObject>("putExtra", "uri", "file:///storage/emulated/0/Download/" + fileName + "/" + pathName);
//intent.Call<AndroidJavaObject>("putExtra", "uri", "file:///storage/emulated/0/Download" + "/fileName" +" /pathName");
intent.Call<AndroidJavaObject>("putExtra", "title", "test.mp4");
intent.Call<AndroidJavaObject>("putExtra", "videoType", "0");//0是2D,1是3D
intent.Call<AndroidJavaObject>("putExtra", "Loop", false);
intent.Call<AndroidJavaObject>("putExtra", "isSinglePlayLoop", false);
context.Call("startActivity", intent);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonOnclickFromBehaviour : MonoBehaviour
{
public Button button_Self;
public string fileName;
public string pathName;
private void Awake()
{
button_Self = this.GetComponent<Button>();
}
private void Start()
{
button_Self.onClick.AddListener(()=>
{
NewBehaviourScript.Instance.StartPlayer(fileName,pathName);
});
}
}