Beispiel #1
0
    /// <summary>
    /// Need to release resources before exiting the application
    /// </summary>
    public void Release()
    {
#if UNITY_ANDROID
        if (IsRelased)
        {
            return;
        }
        IsRelased = true;

        if (PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.Local ||
            PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.LiveUrl)
        {
            if (VideoPlayerPtr == IntPtr.Zero)
            {
                return;
            }
            DestroyVideoPlayer(VideoPlayerPtr);
            VideoPlayerPtr = IntPtr.Zero;
        }
        else if (PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.KTTV)
        {
            mPlayer.release();
        }

        IsVideoReady = false;
        ReadyPlay    = false;
        IsInit       = false;
        mPlayer      = null;
        ResetPlayerTextureDefault();
#endif
    }
Beispiel #2
0
    public void PreparedPlayVideo(Dictionary <string, string> dic)
    {
        if (mPlayer == null)
        {
            mPlayer = new MifengPlayer();
        }

        MediaStretchPlayerPrefsDetector.GetInstance().SetMediaId(string.Format("{0}-{1}", dic["vid"], dic["cid"]));
        mPlayer.setDataSource(dic["vid"], dic["cid"]);
        IsNeedFreeTexeture = true;
        LogTool.Log("播放索引:" + dic["cid"] + "-" + dic["vid"] + " 播放名称:" + dic["name"] + " 播放类型:" + dic["stereoType"]);

        VideoWidth  = 0;
        VideoHeight = 0;
        LogTool.Log("SetDataSource success");
    }
Beispiel #3
0
    private void OnDestroy()
    {
        Release();
        if (ReleaseInterfaceCallback != null)
        {
            ReleaseInterfaceCallback();
        }

        ImageStereoInside = null;
        VideoUnlitForMultiViewMaterial = null;
        VideoMaterial    = null;
        MainTexture      = null;
        QuadScreen       = null;
        HemisphereScreen = null;
        SphereScreen     = null;
        VideoScreen      = null;
        mPlayer          = null;
    }
Beispiel #4
0
    /// <summary>
    /// Before playing video you need create video player first.
    /// Just do once.
    /// </summary>
    public void CreatVideoPlayer()
    {
        if (IsInit)
        {
            return;
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        if (PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.Local ||
            PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.LiveUrl)
        {
            VideoPlayerPtr = CreateVideoPlayer();
            SetOnVolumeChangedEvent2(VideoPlayerPtr, VolumeChangePtr, ToIntPtr(this));
            SetOnVideoEventCallback(VideoPlayerPtr, VideoEventPtr, ToIntPtr(this));
            SetOnExceptionEventCallback(VideoPlayerPtr, ExceptionEventPtr, ToIntPtr(this));

            RenderEventFunction  = GetRenderEventFunc();
            VideoPlayerEventBase = GetVideoPlayerEventBase(VideoPlayerPtr);

            VideoMatrixRaw = new float[16];
            VideoMatrix    = Matrix4x4.identity;
        }
        else if (PlayerDataControl.GetInstance().CurPlayingMode == PlayingURLMode.KTTV)
        {
            if (mPlayer == null)
            {
                mPlayer = new MifengPlayer();
            }
            mPlayer.OnVideoEvent         = OnVideoEvent;
            mPlayer.OnDefnEvent          = OnDefnEvent;
            mPlayer.OnVideoError         = OnExceptionEvent;
            mPlayer.OnVolumeChangedEvent = OnVolumeChangedEvent;
            mPlayer.onUpdateMatrix       = UpdateMatrix;
            mPlayer.OnVieoSize           = OnVieoSizeEvent;
            mPlayer.OnBufferingProgress  = OnVideoEventBufferingProgress;
            mPlayer.createTexture();
        }
        VideoMatrixPropertyId = Shader.PropertyToID("video_matrix");
#endif
        IsInit = true;
    }
 public PlayerEventListener(MifengPlayer player) : base("com.ssnwt.player.PlayerEventListener")
 {
     mPlayer   = player;
     mSTMatrix = new float[16];
 }