Exemplo n.º 1
0
    private void Add(string folder, string filename)
    {
        GameObject go = new GameObject();

        go.transform.parent = _root.transform;

        AVProQuickTimeMovie movie = go.AddComponent <AVProQuickTimeMovie>();

        movie._useStreamingAssetsPath = true;
        movie._folder      = folder;
        movie._filename    = filename;
        movie._loop        = true;
        movie._loadOnStart = false;
        movie._playOnStart = false;

        AVProQuickTimeGUIDisplay gui = go.AddComponent <AVProQuickTimeGUIDisplay>();

        gui._movie      = movie;
        gui._scaleMode  = ScaleMode.StretchToFill;
        gui._fullScreen = false;
        gui._alphaBlend = false;
        gui._depth      = 5;
        gui._color      = new Color(0.8f, 0.8f, 0.8f, 1.0f);

        _movies.Add(gui);

        if (!movie.LoadMovie())
        {
            Remove(gui);
            return;
        }
        else
        {
            movie.Play();
        }

        UpdateLayout();
    }
Exemplo n.º 2
0
    private void ControlWindow(int id)
    {
        if (_movie == null)
        {
            return;
        }

        GUILayout.Space(16f);

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Folder: ", GUILayout.Width(80));
        _movie._folder = GUILayout.TextField(_movie._folder, 192);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("File: ", GUILayout.Width(80));
        _movie._filename = GUILayout.TextField(_movie._filename, 128, GUILayout.Width(350));
        if (GUILayout.Button("Load File", GUILayout.Width(90)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.LocalFile;
            _movie.LoadMovie();
        }
        if (GUILayout.Button("Load URL", GUILayout.Width(90)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.URL;
            _movie.LoadMovie();
        }
#if !UNITY_WEBPLAYER
        if (GUILayout.Button("Load Memory", GUILayout.Width(110)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.Memory;
            string fullPath = System.IO.Path.Combine(_movie._folder, _movie._filename);
            if (System.IO.File.Exists(fullPath))
            {
                _movie._movieData = System.IO.File.ReadAllBytes(fullPath);
                _movie.LoadMovie();
            }
        }
#endif
        GUILayout.EndHorizontal();

        AVProQuickTime moviePlayer = _movie.MovieInstance;
        if (moviePlayer != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Loaded ", GUILayout.Width(80));
            GUILayout.HorizontalSlider(moviePlayer.LoadedSeconds, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
            if (moviePlayer.DurationSeconds > 0f)
            {
                GUILayout.Label(((moviePlayer.LoadedSeconds * 100f) / moviePlayer.DurationSeconds) + "%");
            }
            else
            {
                GUILayout.Label("0%");
            }
            GUILayout.EndHorizontal();


            if (moviePlayer.LoadedSeconds > 0f)
            {
                GUILayout.Label("Resolution: " + moviePlayer.Width + "x" + moviePlayer.Height + " @ " + moviePlayer.FrameRate.ToString("F2") + "hz");


                GUILayout.BeginHorizontal();
                GUILayout.Label("Volume ", GUILayout.Width(80));
                float volume    = _movie._volume;
                float newVolume = GUILayout.HorizontalSlider(volume, 0.0f, 1.0f, GUILayout.Width(200));
                if (volume != newVolume)
                {
                    _movie._volume = newVolume;
                }
                GUILayout.Label(_movie._volume.ToString("F1"));
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Time ", GUILayout.Width(80));
                float position    = moviePlayer.PositionSeconds;
                float newPosition = GUILayout.HorizontalSlider(position, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
                if (position != newPosition)
                {
                    moviePlayer.PositionSeconds = newPosition;
                }
                GUILayout.Label(moviePlayer.PositionSeconds.ToString("F1") + " / " + moviePlayer.DurationSeconds.ToString("F1") + "s");

                if (GUILayout.Button("Play"))
                {
                    moviePlayer.Play();
                }
                if (GUILayout.Button("Pause"))
                {
                    moviePlayer.Pause();
                }

                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();

                GUILayout.Label("Frame " + moviePlayer.Frame.ToString() + " / " + moviePlayer.FrameCount.ToString());

                if (GUILayout.Button("<", GUILayout.Width(50)))
                {
                    if (moviePlayer.Frame > 0)
                    {
                        moviePlayer.Frame--;
                    }
                }
                if (GUILayout.Button(">", GUILayout.Width(50)))
                {
                    moviePlayer.Frame++;
                }

                GUILayout.EndHorizontal();



                if (!moviePlayer.IsPaused)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Rate: " + moviePlayer.PlaybackRate.ToString("F2") + "x");

                    if (GUILayout.Button("Reverse", GUILayout.Width(72)))
                    {
                        moviePlayer.PlaybackRate = -moviePlayer.PlaybackRate;
                    }

                    if (GUILayout.Button("-", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 0.5f;
                    }

                    if (GUILayout.Button("+", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 2.0f;
                    }

                    if (GUILayout.Button("Reset", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = 1.0f;
                    }

                    GUILayout.EndHorizontal();
                }
            }
        }

        GUILayout.EndVertical();
    }
Exemplo n.º 3
0
    private void ControlWindow(int id)
    {
        if (_movie == null)
        {
            return;
        }

        GUILayout.Space(16f);

        GUILayout.BeginVertical();

        _movie._useStreamingAssetsPath = GUILayout.Toggle(_movie._useStreamingAssetsPath, "Use Streaming Assets Folder");

        GUILayout.BeginHorizontal();
        GUILayout.Label("Folder: ", GUILayout.Width(80));
        _movie._folder = GUILayout.TextField(_movie._folder, 192);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("File: ", GUILayout.Width(80));
        _movie._filename = GUILayout.TextField(_movie._filename, 128, GUILayout.Width(350));
        if (GUILayout.Button("Load File", GUILayout.Width(90)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.LocalFile;
            _movie.LoadMovie();
        }
        if (GUILayout.Button("Load URL", GUILayout.Width(90)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.URL;
            _movie.LoadMovie();
        }
#if !UNITY_WEBPLAYER
        if (GUILayout.Button("Load Memory", GUILayout.Width(110)))
        {
            _movie._source = AVProQuickTimePlugin.MovieSource.Memory;
            string fullPath = System.IO.Path.Combine(_movie._folder, _movie._filename);
            if (System.IO.File.Exists(fullPath))
            {
                _movie._movieData = System.IO.File.ReadAllBytes(fullPath);
                _movie.LoadMovie();
                _movie._movieData = null;
            }
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
            System.GC.Collect();
            Debug.Log("GC: " + System.GC.GetTotalMemory(false));
        }
#endif
        GUILayout.EndHorizontal();

        AVProQuickTime moviePlayer = _movie.MovieInstance;
        if (moviePlayer != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Loaded ", GUILayout.Width(80));
            GUILayout.HorizontalSlider(moviePlayer.LoadedSeconds, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
            if (moviePlayer.DurationSeconds > 0f)
            {
                GUILayout.Label(((moviePlayer.LoadedSeconds * 100f) / moviePlayer.DurationSeconds) + "%");
            }
            else
            {
                GUILayout.Label("0%");
            }
            GUILayout.EndHorizontal();

            if (moviePlayer.LoadedSeconds > 0f || AVProQuickTimePlugin.IsMoviePlayable(moviePlayer.Handle))
            {
                GUILayout.Label("Resolution: " + moviePlayer.Width + "x" + moviePlayer.Height + " @ " + moviePlayer.FrameRate.ToString("F2") + "hz");


                GUILayout.BeginHorizontal();
                GUILayout.Label("Volume ", GUILayout.Width(80));
                float volume    = _movie._volume;
                float newVolume = GUILayout.HorizontalSlider(volume, 0.0f, 1.0f, GUILayout.Width(200));
                if (volume != newVolume)
                {
                    _movie._volume = newVolume;
                }
                GUILayout.Label(_movie._volume.ToString("F1"));
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Alpha", GUILayout.Width(80));
                _display._color.a = GUILayout.HorizontalSlider(_display._color.a, 0.0f, 1.0f, GUILayout.Width(200));
                GUILayout.Label(_display._color.a.ToString("F1"));
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Time ", GUILayout.Width(80));
                float position    = moviePlayer.PositionSeconds;
                float newPosition = GUILayout.HorizontalSlider(position, 0.0f, moviePlayer.DurationSeconds, GUILayout.Width(200));
                if (position != newPosition)
                {
                    moviePlayer.PositionSeconds = newPosition;
                    //moviePlayer.Play();
                    //moviePlayer.Update(true);
                }
                GUILayout.Label(moviePlayer.PositionSeconds.ToString("F2") + " / " + moviePlayer.DurationSeconds.ToString("F2") + "s");

                if (GUILayout.Button("Play"))
                {
                    moviePlayer.Play();
                }
                if (GUILayout.Button("Pause"))
                {
                    moviePlayer.Pause();
                }

                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();

                GUILayout.Label("Frame " + moviePlayer.Frame.ToString() + " / " + moviePlayer.FrameCount.ToString());

                if (GUILayout.Button("<", GUILayout.Width(50)))
                {
                    AVProQuickTimePlugin.SeekToPreviousFrame(moviePlayer.Handle);
                }
                if (GUILayout.Button(">", GUILayout.Width(50)))
                {
                    AVProQuickTimePlugin.SeekToNextFrame(moviePlayer.Handle);
                }

                GUILayout.EndHorizontal();

                if (!moviePlayer.IsPaused)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Rate: " + moviePlayer.PlaybackRate.ToString("F2") + "x");

                    if (GUILayout.Button("Reverse", GUILayout.Width(72)))
                    {
                        moviePlayer.PlaybackRate = -moviePlayer.PlaybackRate;
                    }

                    if (GUILayout.Button("-", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 0.5f;
                    }

                    if (GUILayout.Button("+", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = moviePlayer.PlaybackRate * 2.0f;
                    }

                    if (GUILayout.Button("Reset", GUILayout.Width(50)))
                    {
                        moviePlayer.PlaybackRate = 1.0f;
                    }

                    GUILayout.EndHorizontal();
                }
            }
        }

        GUILayout.EndVertical();
    }