コード例 #1
0
        public unsafe int AddMetric(string tag, float minimumValue, float maximumValue, int sampleCount, Func <float> getCurrentValue)
        {
            int id;

            fixed(byte *tagBytes = ResourceLoader.GetBytes(tag))
            {
                id = DllImports.AddGraph(new DllImports.GraphData()
                {
                    tag         = tagBytes,
                    tagLen      = tag.Length,
                    minVal      = minimumValue,
                    maxVal      = maximumValue,
                    valuesCount = sampleCount
                });
            }

            if (id <= DllImports.FpsGraphId)
            {
                return(DllImports.WrongGraphId);
            }
            _metrics.Add(new Metric
            {
                Id     = id,
                Update = getCurrentValue
            });
            DllImports.SetGraphVisibility(id, _metricsShown ? 1 : 0);
            return(id);
        }
コード例 #2
0
 protected override bool OnUpdate()
 {
     UpdateUI();
     NativeActions.GetInstance().Execute();
     DllImports.Draw();
     return(true);
 }
コード例 #3
0
 public override unsafe void Push()
 {
     fixed(byte *p = _data)
     {
         DllImports.AddFont(p, _data.Length);
     }
 }
コード例 #4
0
        private void HandleExternalTileSelection(string url)
        {
            _startedFromDeepLink = true;
            var tileNo = _resourceLoader.ContentList.FindIndex(content =>
                                                               string.Equals(content.Url, url, StringComparison.OrdinalIgnoreCase));

            if (tileNo < 0)
            {
                return;
            }
            if (tileNo == _selectedTile)
            {
                return;
            }
            if (Player != null)
            {
                ClosePlayer();
            }
            _selectedTile = tileNo;
            DllImports.SelectTile(_selectedTile);
            if (_resourceLoader.IsLoadingFinished)
            {
                HandleExternalPlaybackStart();
            }
        }
コード例 #5
0
        private unsafe void UpdatePlaybackControls()
        {
            if (_seekBufferingInProgress == false && _seekInProgress == false)
            {
                _playerTimeCurrentPosition = _player?.CurrentPosition ?? TimeSpan.Zero;
            }
            _playerTimeDuration = _player?.Duration ?? TimeSpan.Zero;
            if (_progressBarShown && _player?.State == PlayerState.Playing &&
                (DateTime.Now - _lastKeyPressTime).TotalMilliseconds >= _progressBarFadeout.TotalMilliseconds)
            {
                _progressBarShown = false;
                _options.Hide();
                Logger?.Info(
                    $"{(DateTime.Now - _lastKeyPressTime).TotalMilliseconds} ms of inactivity, hiding progress bar.");
            }

            fixed(byte *name = ResourceLoader.GetBytes(_resourceLoader.ContentList[_selectedTile].Title))
            {
                DllImports.UpdatePlaybackControls(new DllImports.PlaybackData()
                {
                    show             = _progressBarShown ? 1 : 0,
                    state            = (int)(_player?.State ?? PlayerState.Idle),
                    currentTime      = (int)_playerTimeCurrentPosition.TotalMilliseconds,
                    totalTime        = (int)_playerTimeDuration.TotalMilliseconds,
                    text             = name,
                    textLen          = _resourceLoader.ContentList[_selectedTile].Title.Length,
                    buffering        = _bufferingInProgress ? 1 : 0,
                    bufferingPercent = _bufferingProgress
                });
            }
        }
コード例 #6
0
        private void HandleKeyReturn()
        {
            if (_isAlertShown)
            {
                DllImports.HideAlert();
                _isAlertShown = false;
            }
            else if (_isMenuShown)
            {
                if (_selectedTile >= _resourceLoader.TilesCount)
                {
                    return;
                }
                ShowMenu(false);
                HandlePlaybackStart();
            }
            else if (_progressBarShown && !_options.Visible)
            {
                switch (Player.State)
                {
                case Common.PlayerState.Playing:
                    Player?.Pause();
                    break;

                case Common.PlayerState.Paused:
                    Player?.Start();
                    break;
                }
            }
            else if (_options.Visible && _options.ProperSelection())
            {
                _options.ControlSelect(Player);
                _options.Hide();
            }
        }
コード例 #7
0
        private unsafe void UpdatePlaybackControls()
        {
            if (_progressBarShown && Player?.State == Common.PlayerState.Playing &&
                (DateTime.Now - _lastKeyPressTime).TotalMilliseconds >= _progressBarFadeout.TotalMilliseconds)
            {
                _progressBarShown = false;
                _options.Hide();
                Logger?.Info(
                    $"{(DateTime.Now - _lastKeyPressTime).TotalMilliseconds} ms of inactivity, hiding progress bar.");
            }

            fixed(byte *name = ResourceLoader.GetBytes(_resourceLoader.ContentList[_selectedTile].Title))
            {
                DllImports.UpdatePlaybackControls(new DllImports.PlaybackData()
                {
                    show             = _progressBarShown ? 1 : 0,
                    state            = (int)ToPlayerState(Player?.State ?? Common.PlayerState.Idle),
                    currentTime      = (int)_seekLogic.CurrentPositionUI.TotalMilliseconds,
                    totalTime        = (int)_seekLogic.Duration.TotalMilliseconds,
                    text             = name,
                    textLen          = _resourceLoader.ContentList[_selectedTile].Title.Length,
                    buffering        = _bufferingInProgress ? 1 : 0,
                    bufferingPercent = _bufferingProgress,
                    seeking          = (_seekLogic.IsSeekInProgress || _seekLogic.IsSeekAccumulationInProgress) ? 1 : 0
                });
            }
        }
コード例 #8
0
 public void Update()
 {
     foreach (Metric metric in _metrics)
     {
         DllImports.UpdateGraphValue(metric.Id, metric.Update());
     }
 }
コード例 #9
0
 protected override void OnCreate()
 {
     _uiContext = SynchronizationContext.Current;
     OpenGLLoggerManager.Configure(_uiContext);
     DllImports.Create();
     InitMenu();
 }
コード例 #10
0
 public void SetSeekPreviewReader(StoryboardReader storyboardReader, SeekLogic seekLogic)
 {
     _seekPreviewReader?.Dispose();
     _seekPreviewReader         = storyboardReader;
     seekLogic.StoryboardReader = _seekPreviewReader;
     DllImports.SetSeekPreviewCallback(_getSeekPreviewStoryboardDelegate);
     _seekLogic = seekLogic;
 }
コード例 #11
0
 private void LoadTiles(string dirPath)
 {
     _resourcesTargetCount += ContentList.Count;
     foreach (var contentItem in ContentList)
     {
         LoadAndSchedule(new TileResource(DllImports.AddTile(), Path.Combine(dirPath, "tiles", contentItem.Poster), contentItem.Title ?? "", contentItem.Description ?? ""));
     }
 }
コード例 #12
0
        private static unsafe void SetMenuFooter()
        {
            string footer =
                $"JuvoPlayer v{typeof(Program).Assembly.GetName().Version.Major}.{typeof(Program).Assembly.GetName().Version.Minor}.{typeof(Program).Assembly.GetName().Version.Build}, OpenGL Native #{DllImports.OpenGLLibVersion():x}, Samsung R&D Poland 2017-{DateTime.Now.Year}";

            fixed(byte *f = ResourceLoader.GetBytes(footer))
            DllImports.SetFooter(f, footer.Length);
        }
コード例 #13
0
 private unsafe void UpdateSubtitles()
 {
     if (Player?.CurrentCueText != null && _options.SubtitlesOn)
     {
         fixed(byte *cueText = ResourceLoader.GetBytes(Player.CurrentCueText))
         DllImports.ShowSubtitle(0, cueText,
                                 Player.CurrentCueText.Length); // 0ms duration - special value just for next frame
     }
 }
コード例 #14
0
 private void UpdateState()
 {
     DllImports.SetGraphVisibility(DllImports.FpsGraphId, _metricsShown ? 1 : 0);
     foreach (Metric metric in _metrics)
     {
         DllImports.SetGraphVisibility(metric.Id, _metricsShown ? 1 : 0);
     }
     DllImports.SetLogConsoleVisibility(_metricsShown ? 1 : 0);
 }
コード例 #15
0
 protected override void OnCreate()
 {
     _uiContext = SynchronizationContext.Current;
     OpenGlLoggerManager.Configure(_uiContext);
     _seekLogic = new SeekLogic(this);
     DllImports.Create();
     InitializeKeyHandlersMap();
     InitMenu();
 }
コード例 #16
0
        private void ShowMenu(bool show)
        {
            if (show == _isMenuShown)
            {
                return;
            }

            _isMenuShown = show;
            DllImports.ShowMenu(_isMenuShown ? 1 : 0);
        }
コード例 #17
0
ファイル: OptionsMenu.cs プロジェクト: anomous/JuvoPlayer
 public void ClearOptionsMenu()
 {
     _activeOption      = -1;
     _activeSubOption   = -1;
     _selectedOption    = -1;
     _selectedSubOption = -1;
     Visible            = false;
     SubtitlesOn        = false;
     _streams           = new List <StreamDescriptionsList>();
     DllImports.ClearOptions();
 }
コード例 #18
0
        private void ShowMenu(bool show)
        {
            if (show == _isMenuShown)
            {
                Logger.Info($"ShowMenu({show}) dupe, ignoring.");
                return;
            }

            _isMenuShown = show;
            DllImports.ShowMenu(_isMenuShown ? 1 : 0);
        }
コード例 #19
0
        private void SetDefaultMenuState()
        {
            _isMenuShown = false;

            DllImports.ShowLoader(1, 0);

            _lastKeyPressTime = DateTime.Now;
            _seekLogic.Reset();

            _playbackCompletedNeedsHandling = false;

            _metricsHandler.Hide();
        }
コード例 #20
0
 public override unsafe void Push()
 {
     fixed(byte *p = _image.Pixels)
     {
         DllImports.SetIcon(new DllImports.ImageData
         {
             id     = (int)_type,
             pixels = p,
             width  = _image.Width,
             height = _image.Height,
             format = (int)_image.Format
         });
     }
 }
コード例 #21
0
        private void SetDefaultMenuState()
        {
            _selectedTile = 0;
            DllImports.SelectTile(_selectedTile);
            _isMenuShown = false;
            DllImports.ShowLoader(1, 0);

            _lastKeyPressTime = DateTime.Now;
            _seekLogic.Reset();

            CurrentPositionUI = TimeSpan.Zero;
            _playbackCompletedNeedsHandling = false;

            _metricsHandler.Hide();
        }
コード例 #22
0
        private void ShowMenu(bool show)
        {
            if (show == _isMenuShown)
            {
                return;
            }

            if (!show)
            {
                StoryboardManager.GetInstance().UnloadTilePreview();
            }

            _isMenuShown = show;
            DllImports.ShowMenu(_isMenuShown ? 1 : 0);
        }
コード例 #23
0
ファイル: OptionsMenu.cs プロジェクト: anomous/JuvoPlayer
 private void UpdateOptionsSelection()
 {
     Logger?.Info($"activeOption={_activeOption}, activeSubOption={_activeSubOption}, selectedOption={_selectedOption}, selectedSubOption={_selectedSubOption}");
     if (_selectedOption >= 0 && _selectedOption < _streams.Count)
     {
         _activeSubOption = _streams[_selectedOption].Active;
     }
     DllImports.UpdateSelection(new DllImports.SelectionData()
     {
         show                = Visible ? 1 : 0,
         activeOptionId      = _activeOption,
         activeSubOptionId   = _activeSubOption,
         selectedOptionId    = _selectedOption,
         selectedSubOptionId = _selectedSubOption
     });
 }
コード例 #24
0
        private unsafe void ShowAlert(string title, string body, string button)
        {
            fixed(byte *titleBytes = ResourceLoader.GetBytes(title), bodyBytes = ResourceLoader.GetBytes(body), buttonBytes = ResourceLoader.GetBytes(button))
            {
                DllImports.ShowAlert(new DllImports.AlertData()
                {
                    title     = titleBytes,
                    titleLen  = title.Length,
                    body      = bodyBytes,
                    bodyLen   = body.Length,
                    button    = buttonBytes,
                    buttonLen = button.Length
                });
            }

            _isAlertShown = true;
        }
コード例 #25
0
        private void HandleExternalTileSelection()
        {
            var tileNo = _resourceLoader.ContentList.FindIndex(content =>
                                                               string.Equals(content.Url, _deepLinkUrl, StringComparison.OrdinalIgnoreCase));

            _deepLinkUrl = "";
            if (tileNo == -1 || tileNo == _selectedTile)
            {
                return;
            }
            if (Player != null)
            {
                ClosePlayer();
            }
            _selectedTile = tileNo;
            DllImports.SelectTile(_selectedTile, 0);
            HandleExternalPlaybackStart();
        }
コード例 #26
0
 public override unsafe void Push()
 {
     fixed(byte *p = _image.Pixels, name = GetBytes(_name), desc = GetBytes(_description))
     {
         DllImports.SetTileData(new DllImports.TileData
         {
             tileId            = _id,
             pixels            = p,
             width             = _image.Width,
             height            = _image.Height,
             name              = name,
             nameLen           = _name.Length,
             desc              = desc,
             descLen           = _description.Length,
             format            = (int)_image.Format,
             getStoryboardData = StoryboardManager.GetInstance().AddTile(_id)
         });
     }
 }
コード例 #27
0
 private void HandleKeyRight()
 {
     if (_isMenuShown)
     {
         if (_selectedTile < _resourceLoader.TilesCount - 1)
         {
             _selectedTile = (_selectedTile + 1) % _resourceLoader.TilesCount;
         }
         DllImports.SelectTile(_selectedTile);
     }
     else if (_options.Visible)
     {
         _options.ControlRight();
     }
     else if (_progressBarShown)
     {
         _seekLogic.SeekForward();
     }
 }
コード例 #28
0
 private void HandleKeyLeft()
 {
     if (_isMenuShown)
     {
         if (_selectedTile > 0)
         {
             _selectedTile = (_selectedTile - 1 + _resourceLoader.TilesCount) % _resourceLoader.TilesCount;
         }
         DllImports.SelectTile(_selectedTile);
     }
     else if (_options.Visible)
     {
         _options.ControlLeft();
     }
     else if (_progressBarShown)
     {
         _seekLogic.SeekBackward();
     }
 }
コード例 #29
0
        private async void SetLoaderLogo(string path)
        {
            var imageData = await Resource.GetImage(path);

            NativeActions.GetInstance().Enqueue(() =>
            {
                unsafe
                {
                    fixed(byte *pixels = imageData.Pixels)
                    DllImports.SetLoaderLogo(new DllImports.ImageData
                    {
                        id     = 0,
                        pixels = pixels,
                        width  = imageData.Width,
                        height = imageData.Height,
                        format = (int)imageData.Format
                    });
                }
            });
        }
コード例 #30
0
        private void HandleLoadingFinished()
        {
            _playerWindow = new Window("JuvoPlayer")
            {
                Geometry = new Rect(0, 0, 1920, 1080)
            };
            _playerWindow.Show();
            _playerWindow.Lower();

            if (!_deepLinkUrl.Equals(""))
            {
                HandleExternalTileSelection();
            }
            else
            {
                _selectedTile = 0;
                DllImports.SelectTile(_selectedTile, 0);
                ShowMenu(true);
            }
        }