예제 #1
0
 public void OpenInputField()
 {
     if (InputField.text != MediaPlayer.Path)
     {
         if (System.Uri.IsWellFormedUriString(InputField.text, System.UriKind.Absolute) ||
             System.IO.File.Exists(InputField.text))
         {
             MediaPlayer.Open(InputField.text);
         }
     }
 }
예제 #2
0
    public override void OnInspectorGUI()
    {
        if (!Application.isPlaying)
        {
            UnityEditor.EditorGUILayout.LabelField("You cannot use this editor while in EDIT mode.");
            UnityEditor.EditorGUILayout.LabelField("Hit Play and change the Media Path to begin.");
            return;
        }

        GstreamerPlayer player = (GstreamerPlayer)target;

        if (player == null)
        {
            return;
        }

        if (player.Dimension != Vector2.zero)
        {
            UnityEditor.EditorGUILayout.LabelField("Texture Width", player.Dimension.x.ToString());
            UnityEditor.EditorGUILayout.LabelField("Texture Height", player.Dimension.y.ToString());
        }

        string editor_path = UnityEditor.EditorGUILayout.TextField("Media Absolute Path or URI", player.Path);

        if (editor_path != player.Path)
        {
            if (Uri.IsWellFormedUriString(editor_path, UriKind.Absolute) ||
                System.IO.File.Exists(editor_path))
            {
                player.Open(editor_path);
            }
        }

        if (GUILayout.Button("Open"))
        {
            player.Open(player.Path);
        }
        if (GUILayout.Button("Play"))
        {
            player.Play();
        }
        if (GUILayout.Button("Pause"))
        {
            player.Pause();
        }
        if (GUILayout.Button("Stop"))
        {
            player.Stop();
        }
        if (GUILayout.Button("Close"))
        {
            player.Close();
        }
        if (GUILayout.Button("Replay"))
        {
            player.Replay();
        }

        UnityEditor.EditorGUILayout.LabelField("Current Status", player.Status.ToString());

        bool editor_mute = UnityEditor.EditorGUILayout.Toggle("Mute", player.Mute);

        if (editor_mute != player.Mute)
        {
            player.Mute = editor_mute;
        }

        bool editor_loop = UnityEditor.EditorGUILayout.Toggle("Loop", player.Loop);

        if (editor_loop != player.Loop)
        {
            player.Loop = editor_loop;
        }

        if (player.Duration > 0)
        {
            float editor_pos = UnityEditor.EditorGUILayout.Slider("Time (s)", (float)player.Time, 0.0f, (float)player.Duration);
            if (Mathf.Abs((float)player.Time - editor_pos) > 0.001f * player.Duration)
            {
                player.Time = editor_pos;
            }

            float editor_vol = UnityEditor.EditorGUILayout.Slider("Volume (%)", (float)player.Volume, 0.0f, 1.0f);
            if (editor_vol != player.Volume)
            {
                player.Volume = editor_vol;
            }

            float editor_rate = UnityEditor.EditorGUILayout.FloatField("Playback Rate (negative is reverse)", (float)player.Rate);
            if (editor_rate != player.Rate)
            {
                player.Rate = editor_rate;
            }
        }

        Repaint();
    }