Exemplo n.º 1
0
        private void StartScene()
        {
            if (openScene)
            {
                return;
            }

            if (closed)
            {
                openScene = true;
                closed    = false;

                try
                {
                    Scene sc = null;
                    lock (upscs)
                        sc = upscs[_num];

                    CurrentSceneFileName = sc.Name;

                    switch (MediaType)
                    {
                    case MediaTypeEnum.LOCAL_STREAM:
                        CurrentSceneFileName = new FileInfo(Uri).Directory.FullName + @"\" + sc.Name;
                        break;

                    case MediaTypeEnum.NETWORK_STREAM:
                        CurrentSceneFileName = CacheDirectory + sc.Name;
                        break;
                    }

                    curr_player = !curr_player;

                    if (String.IsNullOrEmpty(MediaElement.FileName) || !MediaElement.FileName.Contains(sc.Name))
                    {
                        MediaElement.Open(CurrentSceneFileName);
                        MediaElement.Play();
                    }
                    else
                    {
                        MediaElement.CurrentPosition = 0;
                        MediaElement.Play();
                    }

                    MediaElement.Volume = volume;
                    MediaElement.BringToFront();
                    MediaElement.AudioStream = 0;

                    buffering = false;
                    if (MediaBuffering != null)
                    {
                        MediaBuffering(this, EventArgs.Empty);
                    }

                    needPosition = 0L;

                    PreloadScene(sc);

                    if (_pos > 0)
                    {
                        MediaElement.CurrentPosition = (double)_pos / 1000.0;
                    }

                    if (_set_on_pause)
                    {
                        if (Mode == PlayerMode.Pause)
                        {
                            MediaElement.Pause();
                        }
                    }

                    if (ffprobe == null || MediaType == MediaTypeEnum.FLAT_FILE)
                    {
                        ffprobe = new Ffprobe(CurrentSceneFileName);
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                }
                finally
                {
                    currentScene = _num;
                    openScene    = false;
                }
            }
        }