public IPlayer GetPlayer(MediaItem mediaItem)
        {
            LibRetroMediaItem retroItem = mediaItem as LibRetroMediaItem;

            if (retroItem == null)
            {
                return(null);
            }
            var player = new LibRetroPlayer();

            player.SetMediaItem(retroItem);
            return(player);
        }
Ejemplo n.º 2
0
        public void SetMediaItem(LibRetroMediaItem mediaItem)
        {
            if (_retro != null)
            {
                return;
            }

            _state = PlayerState.Active;
            IResourceLocator locator = mediaItem.GetResourceLocator();

            string gamePath;

            if (!string.IsNullOrEmpty(mediaItem.ExtractedPath))
            {
                gamePath = mediaItem.ExtractedPath;
            }
            else if (locator.TryCreateLocalFsAccessor(out _accessor))
            {
                gamePath = _accessor.LocalFileSystemPath;
            }
            else
            {
                return;
            }

            string saveName = DosPathHelper.GetFileNameWithoutExtension(locator.NativeResourcePath.FileName);

            ServiceRegistration.Get <ILogger>().Debug("LibRetroPlayer: Creating LibRetroFrontend: Core Path '{0}', Game Path '{1}', Save Name '{2}'", mediaItem.LibRetroPath, gamePath, saveName);

            _corePath     = mediaItem.LibRetroPath;
            _isCoreLoaded = ServiceRegistration.Get <ILibRetroCoreInstanceManager>().TrySetCoreLoading(_corePath);
            if (!_isCoreLoaded)
            {
                ShowLoadErrorDialog();
                return;
            }

            _retro          = new LibRetroFrontend(mediaItem.LibRetroPath, gamePath, saveName);
            _isLibretroInit = _retro.Init();
            //if (_isLibretroInit)
            //{
            //  TimingInfo timingInfo = _retro.GetTimingInfo();
            //  if (timingInfo != null)
            //    MediaItemAspect.SetAttribute(mediaItem.Aspects, VideoAspect.ATTR_FPS, (int)timingInfo.FPS);
            //}
        }