Exemple #1
0
        public Texture2D GetTexture()
        {
            Monitor.Enter(mutex);

            int[]  arr        = { -1 };
            IntPtr changedPtr = (IntPtr)(unmanagedData.ToInt64() + sizeof(int));

            Marshal.Copy(changedPtr, arr, 0, 1);

            if (arr[0] != 0)
            {
                IntPtr colorLocation = (IntPtr)(unmanagedData.ToInt64() + sizeof(int) * 2);
                Marshal.Copy(colorLocation, textureData, 0, (int)(Width * Height * 3));
                Color[] colors = new Color[Width * Height];
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        colors[x + y * Width] = new Color(textureData[3 * (x + y * Width) + 0],
                                                          textureData[3 * (x + y * Width) + 1],
                                                          textureData[3 * (x + y * Width) + 2],
                                                          (byte)255);
                    }
                }
                CrossThread.RequestExecutionOnMainThread(() =>
                {
                    texture.SetData(colors);
                });
                arr[0] = 0;
                Marshal.Copy(arr, 0, changedPtr, 1);
            }

            if (!sound.IsPlaying())
            {
                videos[videoId].sound.Play();
            }

            Monitor.Exit(mutex);

            return(texture);
        }
Exemple #2
0
        public Texture2D GetTexture()
        {
            if (LoadFailed)
            {
                return(null);
            }
            lock (mutex)
            {
                if (textureChanged)
                {
                    texture.SetData(textureData);
                    textureChanged = false;
                }

                if (sound != null && !sound.IsPlaying() && IsPlaying)
                {
                    sound.Play();
                }
            }

            return(texture);
        }