Inheritance: MonoBehaviour
Example #1
0
 void Start()
 {
     if(videoPlayer== null) videoPlayer = gameObject.GetComponent<VideoPlayer>();
     if(videoPlayer == null) Debug.Log("Need VideoPlayer assigned to or on gameObject " + gameObject.name);
     rateSlider.minValue=-4.0f;
     rateSlider.maxValue=4.0f;
 }
Example #2
0
 /// <summary>
 /// Constructs the looping movie runner but does not play the video.
 /// </summary>
 /// <param name="video">Video to play.</param>
 public LoopingMovieRunner(GraphicsDevice graphics, string filename)
 {
     rewindFlag = false;
     this.graphics = graphics;
     player = new VideoPlayer(filename, graphics);
     player.OnVideoComplete += new EventHandler(Player_OnVideoComplete);
 }
        private static void Main(string[] args)
        {
            Player videoPlayer = new VideoPlayer("Sony", 150);

            Console.WriteLine(videoPlayer.ToString());
            videoPlayer.IsOn();
            videoPlayer.TurnOn();
            videoPlayer.TurnOn();
            videoPlayer.IsOn();
            videoPlayer.TurnOff();
            videoPlayer.TurnOff();

            videoPlayer.Play();
            videoPlayer.Play();
            videoPlayer.Stop();

            videoPlayer.TurnOn();
            videoPlayer.Play(new PlayList());
            videoPlayer.Stop();

            videoPlayer.Play(new VideoClip());

            Console.WriteLine(videoPlayer.GetHashCode());
            Console.WriteLine(new VideoPlayer().ToString());
            Console.WriteLine(new VideoPlayer("Grundic", 100).ToString());
        }
Example #4
0
 protected override void OnClosing(CancelEventArgs e)
 {
     player.AllowClose = true;
     player.Close();
     player = null;
     base.OnClosing(e);
 }
 void Start()
 {
     //if you want  you can have add the player onto a game object  gameObject.AddComponent<VideoPlayer>();
     video = GetComponent<VideoPlayer> ();// find a video player on this game object
     if (video.videoIndex == 0) {
         video.PlayTexture(videoForIndex0);
     }
     else
         video.PlayTexture (videoForIndex1);
 }
Example #6
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        cameraScript = GetComponent<MoveCamera>();
        soundScript = myCamera.GetComponent<SoundManager>();
        zapScript = myCamera.GetComponent<EffectZapping>();
        videoPlayer = FindObjectOfType<VideoPlayer>();
    }
Example #7
0
 void Update()
 {
     if(videoPlayer.Finished && !_creditsStarted)
     {
         // play credits
         outro.SetActive(false);
         outroH.SetActive(false);
         credits.SetActive(true);
         _creditsStarted = true;
         videoPlayer = credits.GetComponent<VideoPlayer>();
         videoPlayer.PlayMovieAndLoadScene(0);
     }
 }
Example #8
0
        protected override void Init()
        {
            base.Init();

            _ThemeName = "ScreenLoad";
            _ScreenVersion = ScreenVersion;
            _ThemeTexts = new string[] { TextStatus };
            _Intros = new VideoPlayer[IntroVideo.Length];
            for (int i = 0; i < _Intros.Length; i++)
            {
                _Intros[i] = new VideoPlayer();
            }
            _timer = new Stopwatch();
        }
    IEnumerator Start()
    {
        //if you want  you can have add the player onto a game object  gameObject.AddComponent<VideoPlayer>();
        video = GetComponent<VideoPlayer> ();// find a video player on this game object
        if (video.videoIndex == 0) {
            video.PlayTexture(videoForIndex0);
            yield return new WaitForSeconds( duration );
            FadeImg.color = Color.Lerp(FadeImg.color, Color.black, fadeSpeed * Time.deltaTime);
            video.Stop();
            Application.LoadLevel(nextScene);

        }
        else
            video.PlayTexture (videoForIndex1);
    }
Example #10
0
    void Start()
    {
        if (GameManager.instance.GameOver)
        {
            if (GameManager.instance.Won)
            {
                outro.SetActive(false);
                outroH.SetActive(true);
                credits.SetActive(false);

                videoPlayer = outroH.GetComponent<VideoPlayer>();
            }
            else
            {
                outro.SetActive(true);
                outroH.SetActive(false);
                credits.SetActive(false);

                videoPlayer = outro.GetComponent<VideoPlayer>();
            }

            videoPlayer.PlayMovie();
        }
    }
Example #11
0
    IEnumerator playVideo()

    {
        //Add VideoPlayer to the GameObject
        videoPlayer = gameObject.AddComponent <VideoPlayer>();

        //Add AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();

        //Disable Play on Awake for both Video and Audio

        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        audioSource.Pause();

        //We want to play from video clip not from url
        videoPlayer.source = VideoSource.VideoClip;

        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);

        //Set video To Play then prepare Audio to prevent Buffering
        videoPlayer.clip = videoToPlay;
        videoPlayer.Prepare();

        //Wait until video is prepared
        while (!videoPlayer.isPrepared)

        {
            yield return(null);
        }

        Debug.Log("Done Preparing Video");

        //Assign the Texture from Video to RawImage to be displayed
        image.texture = videoPlayer.texture;

        //Play Video
        videoPlayer.Play();

        //Play Sound
        audioSource.Play();

        Debug.Log("Playing Video");
        while (videoPlayer.isPlaying)

        {
            Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)videoPlayer.time));

            yield return(null);
        }



        Debug.Log("Done Playing Video");
        finished = true;
    }
Example #12
0
 private void OnStarted(VideoPlayer player)
 {
 }
Example #13
0
 // Start is called before the first frame update
 void Start()
 {
     videoPlayer = gameObject.AddComponent <VideoPlayer>();
     audioSource = gameObject.AddComponent <AudioSource>();
     LoadAndPlay();
 }
Example #14
0
/* A function used to record the videoPlayer's prepareCompleted event */
    private void VideoPreparationCompleted(VideoPlayer videoPlayer)
    {
        videoIsPrepared = true;
    }
Example #15
0
 private void OnVideoError(VideoPlayer player, string message)
 {
     Debug.LogError($"VideoPlayer got error: {message}");
     StopVideo();
 }
 void Awake()
 {
     videoPlayer = GetComponent <VideoPlayer> ();
 }
 private void VideoPlayer_loopPointReached(VideoPlayer source)
 {
     currentVideo = (currentVideo + 1) % urls.Length;
     LoadVideo();
 }
Example #18
0
 void Start()
 {
     if(videoPlayer== null) videoPlayer = gameObject.GetComponent<VideoPlayer>();
     if(videoPlayer == null) Debug.Log("Need VideoPlayer assigned to or on gameObject " + gameObject.name);
 }
Example #19
0
    private VideoPlayer videoPlayer; //视频播放组件

    private void Start()
    {
        rawImage    = GetComponent <RawImage>();
        videoPlayer = GetComponent <VideoPlayer>();
    }
Example #20
0
 void OnFrameDropped(VideoPlayer source)
 {
     Fsm.EventData.GameObjectData = source.gameObject;
     Fsm.Event(onFrameDroppedEvent);
 }
Example #21
0
 private void frmAdd_FormClosing(object sender, FormClosingEventArgs e)
 {
     VideoPlayer.Stop();
 }
Example #22
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     VideoPlayer.Stop();
     this.Close();
 }
Example #23
0
 private void videoPlayer_NextFrame(VideoPlayer sender, NextFrameEventArgs args)
 {
     video.Image = videoPlayer.LastFrame.ToBitmap();
     ProcessMeanShift();
     ProcessBackgroundSubtraction();
 }
        public VideoPanelViewModel()
		{
			
			//
			//TODO: Add the constructor code here
			//
			//videoRender = null;
			//mediaPlayer.Dock = DockStyle.Fill;
			//mediaPlayer.stretchToFit = true;


			videoRender = new VideoRender(VideoPanel);
			audioPlayer = new StreamingAudioBuffer(this);

			//videoRender.initialize(0,0);
			videoDecoder = new VideoPlayer();	
			videoDecoder.FrameQueue.Closed += new EventHandler(frameQueue_Closed);

			videoDecoder.setLogCallback(new VideoPlayer.LogCallbackDelegate(videoDecoderLogCallback),
				true, true);
			
			videoRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
			videoRefreshTimer.Tick += new EventHandler(videoRefreshTimer_Tick);
			//videoRefreshTimer.SynchronizingObject = this;
			videoRefreshTimer.AutoReset = false;

			audioRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
			audioRefreshTimer.Tick += new EventHandler(audioRefreshTimer_Tick);
			audioRefreshTimer.AutoReset = false;
			audioRefreshTimer.SynchronizingObject = null;

			videoDebug = new VideoDebugForm();

			audioDiffAvgCoef  = Math.Exp(Math.Log(0.01) / AUDIO_DIFF_AVG_NB);

			//syncMode = SyncMode.VIDEO_SYNCS_TO_AUDIO;
			syncMode = SyncMode.AUDIO_SYNCS_TO_VIDEO;
			VideoState = VideoState.CLOSED;

			updateTimeTrackBar = true;

			timeTrackBarToolTip = new CustomToolTip();
			timeTrackBarToolTip.BackColor = SystemColors.Info;
			this.Controls.Add(timeTrackBarToolTip);

			timeTrackBarToolTip.Show();
			timeTrackBarToolTip.BringToFront();
			timeTrackBarToolTip.Visible = false;			
			
			muteCheckBox.Checked = bool.Parse(Settings.getVar(Settings.VarName.VIDEO_MUTED));
			volumeTrackBar.Value = Util.lerp<int>(Double.Parse(Settings.getVar(Settings.VarName.VIDEO_VOLUME)), volumeTrackBar.Minimum, volumeTrackBar.Maximum);

		}
Example #25
0
 private void Awake()
 {
     camara = GetComponent <Camera>();
     video  = GetComponent <VideoPlayer>();
 }
Example #26
0
 /// <summary>
 /// Dispose of the video and stop playing.
 /// </summary>
 public void UnloadContent()
 {
     try
     {
         graphics = null;
         Stop();
         player.Dispose();
         player = null;
     }
     catch
     {
         // Unloads take place upon shutdown, so exceptions don't matter.
     }
 }
Example #27
0
 private void PauseButton_Click(object sender, RoutedEventArgs e)
 {
     VideoPlayer.Pause();
 }
 void Start()
 {
     video = GetComponent<VideoPlayer>();
 }
 void seekCompleted(VideoPlayer v)
 {
     Debug.Log("video player finished seeking");
     isDone = false;
 }
Example #30
0
 void LoadScene(VideoPlayer vp)
 {
     SceneManager.LoadScene(int.Parse(SceneToLoad.text));
 }
 void started(VideoPlayer v)
 {
     Debug.Log("video player finished started");
 }
Example #32
0
    IEnumerator playVideo()
    {
        videoNumber++;
        //Add VideoPlayer to the GameObject
        videoPlayer = gameObject.AddComponent <VideoPlayer>();

        //Add AudioSource
        audioSource = gameObject.AddComponent <AudioSource>();

        //Disable Play on Awake for both Video and Audio
        videoPlayer.playOnAwake = false;
        audioSource.playOnAwake = false;
        audioSource.Pause();

        //We want to play from video clip not from url

        videoPlayer.source = VideoSource.VideoClip;

        //Video clip from Url
        videoPlayer.source = VideoSource.Url;
        videoPlayer.url    = Application.streamingAssetsPath + "/" + movieName[videoNumber] + ".mp4";


        //Set Audio Output to AudioSource
        videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

        //Assign the Audio from Video to AudioSource to be played
        videoPlayer.EnableAudioTrack(0, true);
        videoPlayer.SetTargetAudioSource(0, audioSource);
        videoPlayer.controlledAudioTrackCount = 1;
        //Set video To Play then prepare Audio to prevent Buffering
        //for(videoNumber = 0; videoNumber <= 7; videoNumber++)
        //{
        videoPlayer.clip = vid[videoNumber];
        //     }

        //loadFS.OnMouseEnter();
        videoPlayer.Prepare();

        //Wait until video is prepared
        while (!videoPlayer.isPrepared)
        {
            yield return(null);
        }
        //loadFS.OnMouseExit();
        Debug.Log("Done Preparing Video");

        //Assign the Texture from Video to RawImage to be displayed
        display.texture = videoPlayer.texture;

        //Play Video
        videoPlayer.Play();

        //Play Sound
        audioSource.Play();


        Debug.Log("Playing Video");
        while (videoPlayer.isPlaying)
        {
            //Debug.LogWarning("Video Time: " + Mathf.FloorToInt((float)videoPlayer.time));
            yield return(null);
        }

        Debug.Log("Done Playing Video");
        LoadBaseScene();

        //      if ((videoNumber > 0 && videoNumber < 1) || (videoNumber > 0 && videoNumber < 6)) {
        //	CallVideo ();
        //         // print(" hiii video playing");
        //	Debug.Log ("1");
        //}
        //else if (videoNumber == 0)
        //{
        //	Debug.Log ("2");
        //	//starterPanel.SetActive (true);
        //	InitialBG.SetActive (false);
        //	if (audioSource.isPlaying) {
        //		videoPlayer.Stop ();
        //		audioSource.Stop ();
        //	}
        //}
        //else if (videoNumber == 6) {
        //	Debug.Log ("3");
        //	LoadBaseScene ();
        //}
        //else {
        //	Debug.Log ("4");
        //}
    }
Example #33
0
        private void openPreview(MainForm mainForm)
        {
            player = new VideoPlayer();
            bool videoLoaded = player.loadVideo(mainForm, scriptName, PREVIEWTYPE.ZONES, false);
            if (!videoLoaded) return;

            startFrame.Maximum = endFrame.Maximum = player.Reader.FrameCount - 1;
            cuts.Framerate = player.Framerate;
            avsScript.Text += "   (" + cuts.Framerate.ToString("##.###") + "FPS)";

            player.AllowClose = false;
            player.ZoneSet += new ZoneSetCallback(player_ZoneSet);
            player.Show();
        }
Example #34
0
    // Use this for initialization
    void Start()
    {
        osc = GetComponent <OSC>();
        osc.SetAllMessageHandler(OnOSCMessage);
        string allScript = GetScriptItems();

        string[]   lines         = allScript.Split('\n');
        ScriptItem curItem       = null;
        AreaChange newAreaChange = null;

        foreach (string lineRaw in lines)
        {
            string line = lineRaw.Trim();
            if (line.StartsWith("AREA:"))
            {
                DisplayArea newArea = new DisplayArea();
                string []   values  = line.Substring(5).Split(',');
                for (int c = 0; c < values.Length; c++)
                {
                    switch (c)
                    {
                    case 0:
                        newArea.name = values[c];
                        break;

                    case 1:
                        newArea.fontName = values[c];
                        break;

                    case 2:
                        int.TryParse(values[c], out newArea.fontSize);
                        break;

                    case 3:
                        int.TryParse(values[c], out newArea.r);
                        break;

                    case 4:
                        int.TryParse(values[c], out newArea.g);
                        break;

                    case 5:
                        int.TryParse(values[c], out newArea.b);
                        break;

                    case 6:
                        float.TryParse(values[c], out newArea.x0);
                        break;

                    case 7:
                        float.TryParse(values[c], out newArea.y0);
                        break;

                    case 8:
                        float.TryParse(values[c], out newArea.x1);
                        break;

                    case 9:
                        float.TryParse(values[c], out newArea.y1);
                        break;
                    }
                }


                GameObject imgChild = new GameObject("img " + newArea.name);
                imgChild.transform.SetParent(canvas.transform, false);
                RawImage      image = imgChild.AddComponent <RawImage>();
                RectTransform tf2   = imgChild.GetComponent <RectTransform>();
                tf2.anchorMin         = new Vector2(newArea.x0, newArea.y0);
                tf2.anchorMax         = new Vector2(newArea.x1, newArea.y1);
                tf2.offsetMin         = new Vector2(0, 0);
                tf2.offsetMax         = new Vector2(0, 0);
                newArea.image         = image;
                newArea.image.enabled = false;


                RenderTexture vidTex = new RenderTexture(1024, 1024, 0);
                vidTex.Create();

                GameObject vidChild = new GameObject("vid " + newArea.name);
                vidChild.transform.SetParent(canvas.transform, false);

                RawImage vImage = vidChild.AddComponent <RawImage>();
                vImage.texture = vidTex;
                RectTransform tf3 = vidChild.GetComponent <RectTransform>();
                tf3.anchorMin = new Vector2(newArea.x0, newArea.y0);
                tf3.anchorMax = new Vector2(newArea.x1, newArea.y1);
                tf3.offsetMin = new Vector2(0, 0);
                tf3.offsetMax = new Vector2(0, 0);

                VideoPlayer vidPlayer = vidChild.AddComponent <VideoPlayer>();
                vidPlayer.renderMode    = VideoRenderMode.RenderTexture;
                vidPlayer.targetTexture = vidTex;
                newArea.video           = vidPlayer;
                newArea.vidTex          = vidTex;
                newArea.videoImage      = vImage;



                GameObject textChild = new GameObject("txt " + newArea.name);
                textChild.transform.SetParent(canvas.transform, false);
                Text txt = textChild.AddComponent <Text>();
                txt.text      = "";
                txt.color     = new Color(((float)newArea.r) / 255.0f, ((float)newArea.g) / 255.0f, ((float)newArea.b) / 255.0f);
                txt.alignment = TextAnchor.MiddleLeft;
                txt.font      = Font.CreateDynamicFontFromOSFont(newArea.fontName, 36);
                txt.fontSize  = newArea.fontSize;

                RectTransform tf = textChild.GetComponent <RectTransform>();
                tf.anchorMin = new Vector2(newArea.x0, newArea.y0);
                tf.anchorMax = new Vector2(newArea.x1, newArea.y1);
                tf.offsetMin = new Vector2(0, 0);
                tf.offsetMax = new Vector2(0, 0);

                newArea.text = txt;

                areas.Add(newArea);
            }
            else
            {
                print(line);
                bool firstLine = (line.Length > 0 && line[0] == '#');
                if (firstLine)
                {
//                    print(line);
                    if (newAreaChange != null)
                    {
                        newAreaChange.text = newAreaChange.text.Trim();
                        curItem.changes.Add(newAreaChange);
                    }
                    newAreaChange = new AreaChange();
                    string [] cueData = line.Substring(1).Split(',');
                    if (cueData.Length > 1)
                    {
                        newAreaChange.displayArea = cueData[1];
                    }
                    curItem = null;
                    for (int c = 0; c < items.Count; c++)
                    {
                        if (items[c].cueID == cueData[0])
                        {
                            curItem = items[c];
                            break;
                        }
                    }
                    if (curItem == null)
                    {
                        curItem       = new ScriptItem();
                        curItem.cueID = cueData[0];
                        items.Add(curItem);
                        print(items.Count + "!");
                    }
                }
                else
                {
                    if (newAreaChange != null)
                    {
                        if (line.StartsWith("[") && line.IndexOf("]") > 0)
                        {
                            newAreaChange.image = LoadScriptImage(line.Substring(1, line.IndexOf("]") - 1));
                        }
                        else if (line.StartsWith("{") && line.IndexOf("}") > 0)
                        {
                            newAreaChange.movieName = LoadScriptVideo(line.Substring(1, line.IndexOf("}") - 1));
                        }
                        else
                        {
                            newAreaChange.text += line + "\n";
                        }
                    }
                }
            }
        }
        if (newAreaChange != null)
        {
            newAreaChange.text = newAreaChange.text.Trim();
            curItem.changes.Add(newAreaChange);
        }
    }
 void Start()
 {
     video = GetComponent<VideoPlayer> ();// find a video player on this game object
 }
 // functions for debuging video player
 void errorReceived(VideoPlayer v, string msg)
 {
     Debug.Log("video player eero: " + msg);
 }
 private void _PrepareCompleted(VideoPlayer player)
 {
     RawImage.texture = player.texture;
 }
Example #38
0
 // Use this for initialization
 void Start()
 {
     scaleSmall     = new Vector3(.01f, .01f, .01f);
     displayGo      = GameObject.CreatePrimitive(PrimitiveType.Quad);
     displayGo.name = "display";
     videoPlayer    = displayGo.AddComponent <VideoPlayer>();
     displayGo.transform.localScale = Vector3.zero;
     //
     videoGos     = new GameObject[numNodes];
     videoClips   = new VideoClip[numNodes];
     videoPlayers = new VideoPlayer[numNodes];
     targetsPos   = new Vector3[numNodes];
     origsPos     = new Vector3[numNodes];
     looksPos     = new Vector3[numNodes];
     targetsScale = new Vector3[numNodes];
     origsScale   = new Vector3[numNodes];
     looksScale   = new Vector3[numNodes];
     audioSources = new AudioSource[numNodes];
     for (int n = 0; n < numNodes; n++)
     {
         videoGos[n]      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         videoGos[n].name = "video " + n;
         float   ang = 360f / numNodes * n;
         float   rad = 5 * scale;
         float   x   = rad * Mathf.Cos(ang * Mathf.Deg2Rad);
         float   y   = rad * Mathf.Sin(ang * Mathf.Deg2Rad);
         float   z   = n * 2 * scale;
         Vector3 pos = new Vector3(x, y, z);
         videoGos[n].transform.position = Vector3.zero;
         Vector3 sca = new Vector3(2 * scale, 2 * scale, 1 * scale);
         videoGos[n].transform.localScale = sca;
         videoPlayers[n]           = videoGos[n].AddComponent <VideoPlayer>();
         videoPlayers[n].clip      = videoClips[n];
         videoPlayers[n].isLooping = true;
         //
         audioSources[n] = videoGos[n].AddComponent <AudioSource>();
         videoPlayers[n].audioOutputMode = VideoAudioOutputMode.AudioSource;
         videoPlayers[n].EnableAudioTrack(0, true);
         videoPlayers[n].SetTargetAudioSource(0, audioSources[n]);
         if (n == 0)
         {
             videoPlayers[n].url = Application.streamingAssetsPath + "/" + "SampleVideo_640x360_5mb.mp4";
         }
         else
         {
             if (n == 1)
             {
                 videoPlayers[n].url = Application.streamingAssetsPath + "/" + "small.mp4";
             }
             else
             {
                 videoPlayers[n].url = Application.streamingAssetsPath + "/" + "CountDown" + n + ".mov";
             }
         }
         videoPlayers[n].Prepare();
         audioSources[n].mute = true;
         targetsPos[n]        = pos;
         origsPos[n]          = pos;
         targetsScale[n]      = sca;
         origsScale[n]        = sca;
     }
 }
 // how many frame in the video
 void frameReady(VideoPlayer v, long frame)
 {
 }
Example #40
0
        void Loading()
        {
            t_Tick = Content.Load<Texture2D>("MenusBGrounds//Tick");
            t_Cross = Content.Load<Texture2D>("MenusBGrounds//Cross");
            t_UnderScore = Content.Load<Texture2D>("MenusBGrounds//Underscore");
            t_HighScore = Content.Load<Texture2D>("MenusBGrounds//High score screen");
            t_GOContinue = Content.Load<Texture2D>("MenusBGrounds//continue");
            t_GOQuit = Content.Load<Texture2D>("MenusBGrounds//Game_over_quit");
            t_GORetry = Content.Load<Texture2D>("MenusBGrounds//retry");
            t_Pixel = Content.Load<Texture2D>("mightypixel");

            v_Video1 = new VideoPlayer(@"intro.avi", GraphicsDevice);
            v_Video1.Play();
            MenuMusic.Pause();
        }
 void loopPointReached(VideoPlayer v)
 {
     Debug.Log("video player loop point reached");
     isDone = true;
 }
Example #42
0
 public bool IsActive(VideoPlayer p)
 {
     IVideoPlayer v = Players.FirstOrDefault(a => a.Player == p);
     if (v == null)
         return false;
     v.Init();
     return v.Active;
 }
Example #43
0
        /// <summary>
        /// Plays a video, replacing the current video player.
        /// </summary>
        /// <param name="filename"></param>
        public void Play(string filename)
        {
            Stop();
            if (player != null)
                player.Dispose();

            player = new VideoPlayer(filename, graphics);
            player.OnVideoComplete += new EventHandler(Player_OnVideoComplete);
            Play();
        }
Example #44
0
 public StreamTarget(VideoPlayer player, bool video, string name)
 {
     this.Player = player;
     this.HasVideo = video;
     this.Name = name;
 }
Example #45
0
    public async static void PlayLogoVideo(VideoPlayer v, RawImage rawImage)
    {
        if (videoFinished)
        {
            rawImage.gameObject.SetActive(false);
            return;
        }

        videoPlayer = v;
        string p = Path.Combine(PathHelper.AppHotfixResPath, "logo.unity3d");

        if (!File.Exists(p))
        {
            p = Path.Combine(PathHelper.AppResPath, "logo.unity3d");
        }

        if (!File.Exists(p) && Application.isEditor)
        {
            p = Path.Combine(Application.dataPath, "Videos/StandaloneWindows/logo.unity3d");
        }

        VideoClip vc = null;

        try
        {
            Log.Debug(p);
            foreach (var ab in AssetBundle.GetAllLoadedAssetBundles())
            {
                if (ab.Contains("logo"))
                {
                    vc = ab.LoadAsset <VideoClip>("logo");
                    break;
                }
            }
            if (vc == null)
            {
                vc = AssetBundle.LoadFromFile(p).LoadAsset <VideoClip>("logo");
            }
        }
        catch (System.Exception e)
        {
            videoFinished = true;
            rawImage.gameObject.SetActive(false);
            Log.Debug(e.ToString());
            return;
        }

        v.clip = vc;
        //v.url = p;
        v.Prepare();

        v.playOnAwake = false;
        int count = 0;

        while (v != null && !v.isPrepared)
        {
            count++;
            if (count > 60)
            {
                rawImage.gameObject.SetActive(false);
                videoFinished = true;
                Log.Debug("video Finished 2");
                return;
            }
            await UniTask.DelayFrame(1);
        }
        if (v == null)
        {
            return;
        }

        renderTexture?.DiscardContents();
        renderTexture?.Release();

        renderTexture   = new RenderTexture(1280, 720, 0, RenderTextureFormat.ARGB32);
        v.targetTexture = renderTexture;
        var image = v.GetComponent <RawImage>();

        image.color   = Color.white;
        image.texture = renderTexture;
        v.Play();
        rawImage.texture = renderTexture;
        rawImage.color   = Color.white;
        while (v != null && v.isPlaying)
        {
            await UniTask.DelayFrame(1);
        }

        //rawImage.gameObject.SetActive(false);

        videoFinished = true;
        Log.Debug("video finished 3");
    }
        private void BtnVideoPlay_Click(object sender, RoutedEventArgs e)
        {
            if (this.VideoViewer == null || !this.VideoViewer.IsLoaded)
            {
                this.VideoViewer = new VideoPlayWindow();
                this.VideoViewer.Show();

                WindowInteropHelper wnd = new WindowInteropHelper(this.VideoViewer);
                this.MyVideoPlayer = new VideoPlayer(wnd.Handle, @"output.mp4");
            }

            bool result = this.MyVideoPlayer.Play();

            if (!result)
            {
                MessageBox.Show("動画の再生に失敗しました。", "Error");
            }

            this.VideoState = PlayerState.Playing;
            this.NotifyPropertyChanged("IsVideoPlayButtonEnable");
            this.NotifyPropertyChanged("IsVideoPauseButtonEnable");
            this.NotifyPropertyChanged("IsVideoStopButtonEnable");
        }
Example #47
0
 // Start is called before the first frame update
 void Start()
 {
     videoPlayer             = GetComponent <VideoPlayer>();
     videoPlayer.playOnAwake = true;
     videoPlayer.clip        = videos[0];
 }
Example #48
0
 void Start()
 {
     //if you want  you can have add the player onto a game object  gameObject.AddComponent<VideoPlayer>();
         video = GetComponent<VideoPlayer> ();// find a video player on this game object
 }
Example #49
0
 void EndReached(VideoPlayer videoplayer)
 {
     Debug.Log("End Reached");
     ToBook.allowSceneActivation = true;
 }
 // new video is prepared
 void prepareCompleted(VideoPlayer v)
 {
     Debug.Log("video player finished prepareing");
     isDone = false;
 }
Example #51
0
 // Start is called before the first frame update
 void Start()
 {
     cutscene = this.gameObject.GetComponent <VideoPlayer>();
 }
Example #52
0
 void Start()
 {
     videoPlayer = GetComponent <VideoPlayer>();
     SelectRandomVideo();
     CycleMangaPanel();
 }
Example #53
0
File: temp.cs Project: tesidroni/mp
        private void but_rtspurl_Click(object sender, EventArgs e)
        {
            string url = "rtsp://192.168.1.252/";
            InputBox.Show("video address", "enter video address", ref url);

            factory = new Factory();

            media = factory.CreateMedia(url);

            player = factory.CreatePlayer();

            renderer = player.Renderer;

            player.Open(media);

            renderer.SetFormat(new BitmapFormat(512, 512, ChromaType.RV32));

            player.Play();
        }