1.为什么要调用ios原生视播放
unity 虽然有播放视频的方法
Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
但是这个不能设置 大小 ,播放状态 等 局限性很大
2.使用ios AVPlayer 播放视频
1.unity中的c#代码
上面是封装到一个类里
其实可以直接调用
比如你unity里面一个物体上挂了一个脚本
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class NewBehaviourScript : MonoBehaviour {
[DllImport("__Internal")] //声明是调用ios代码
private static extern void setIosVideoUrl(string url,string objName);
[DllImport("__Internal")]
private static extern void setIosVideoRect(int left,int top,int width,int height);
[DllImport("__Internal")]
private static extern void VideoPlay();
// Use this for initialization
void Start () {
//视频要放在Assets\StreamingAssets\ 路径下面
setIosVideoUrl("101.mp4","当前挂载脚本物体名称"); //这里就可以直接调用
setIosVideoRect(20,20,200,200);
VideoPlay();
}
// Update is called once per frame
void Update () {
}
}
2.ios里面调用视频播放的接口代码
#include <string>
#import "AVPlayerContr