void Start() { //Debug.Log("Start"); if (player == null) { return; } _eventSystem = FindObjectOfType <EventSystem>(); _button = GetComponent <Button>(); if (_button) { _colorBlock = _button.colors; } switch (mode) { case Mode.LOAD: OnSelected = new Action(() => { player.Load(); }); break; case Mode.PLAY: OnSelected = new Action(() => { player.Play(); }); break; case Mode.PAUSE: OnSelected = new Action(() => { player.Pause(); }); break; case Mode.STOP: OnSelected = new Action(() => { player.Stop(); }); break; case Mode.SEEK: _slider = GetComponent <Slider>(); OnDraged = new Action <float>((f) => { player.SeekTo(f, true); }); break; case Mode.VOLUME: _slider = GetComponent <Slider>(); OnDraged = new Action <float>((f) => { player.volume = f; }); break; case Mode.LOOP: _toggle = GetComponent <Toggle>(); if (_toggle) { OnSelected = new Action(() => { player.looping = !_toggle.isOn; }); } break; case Mode.AUTOPLAY: _toggle = GetComponent <Toggle>(); if (_toggle) { OnSelected = new Action(() => { player.autoPlay = !_toggle.isOn; }); } break; case Mode.TEXTURE: _rawImage = GetComponent <RawImage>(); if (_rawImage) { #if !UNITY_ANDROID || UNITY_EDITOR Rect uvr = _rawImage.uvRect; //#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN //uvr.height *= -1f; //#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS uvr.y = 1f; uvr.height *= -1f; //#endif _rawImage.uvRect = uvr; #endif } break; case Mode.PLAYBACKRATE: _slider = GetComponent <Slider>(); OnDraged = new Action <float>((f) => { player.rate = f; }); break; case Mode.TIME: _text = GetComponent <Text>(); _timeSB = new StringBuilder(); if (_text != null) { OnUpdateTime = new Action <double, double>((pos, dur) => { _timeSB.Length = 0; _timeSB.Capacity = 0; try { minPos = (int)Mathf.Floor(Convert.ToInt32(pos * dur) / 60f); secPos = (int)(Convert.ToInt32(pos * dur) - (minPos * 60)); minDur = (int)Mathf.Floor(Convert.ToInt32(dur) / 60f); secDur = (int)(Convert.ToInt32(dur) - (minDur * 60)); }catch (Exception) { }; /* * if (secPos < 10) * { * _timeSB.AppendFormat("{0}:0{1} / {2}:{3}", minPos, secPos, minDur, secDur); * } * else * { * _timeSB.AppendFormat("{0}:{1} / {2}:{3}", minPos, secPos, minDur, secDur); * } */ _timeSB.AppendFormat(timeText, minPos, secPos, minDur, secDur); _text.text = _timeSB.ToString(); //Debug.Log(String.Format("pos:{0}, dur:{1}", pos,dur)); }); } break; case Mode.PATH: _inputField = GetComponent <InputField>(); if (_inputField != null) { _curPath = _oldPath = _inputField.text = player.videoPath; OnUpdate = new Action(() => { _curPath = _inputField.text; if (_curPath != _oldPath) { //input field change player.videoPath = _curPath; } else if (player.videoPath != _curPath) { //videopath was changed _curPath = _inputField.text = player.videoPath; } _oldPath = _curPath; }); } break; } }
public override void Pause() { _mediaPlayer.Pause(); Events.OnClipPlaybackPaused(); }