Example #1
0
        private void OnApplicationQuit()
        {
            if (ValidatePlayerId(_id))
            {
                var result = ReleasePlayer(_id);

                if (result < 0)
                {
                    throw new Exception($"Failed to release player with error: {_id}");
                }
            }

            NativeInitializer.Teardown();
        }
Example #2
0
        private void Start()
        {
            NativeInitializer.Initialize(this);

            var uri = string.Copy(Uri);

            if (!Uri.Contains(RTSPPrefix))
            {
                uri = Application.streamingAssetsPath + Path.DirectorySeparatorChar + Uri;

                // ensure the file exists before moving forward
                if (!File.Exists(uri))
                {
                    throw new FileNotFoundException($"{uri} not found.");
                }
            }

            // create the texture to write to
            _targetTexture = new Texture2D(Width, Height, TextureFormat.ARGB32, false)
            {
                filterMode = FilterMode.Bilinear,
                name       = Uri
            };

            // register the texture and get the id from the native plugin
            _id = GetPlayer(uri, _targetTexture.GetNativeTexturePtr());

            if (ValidatePlayerId(_id))
            {
                TargetMaterial.mainTexture = _targetTexture;
            }
            else
            {
                throw new Exception($"Failed to create player with error: {_id}");
            }

            if (AutoPlay)
            {
                Play();
            }
        }