Exemplo n.º 1
0
        public void TestAllowedTypesString()
        {
            var fls = new FileLoading();

            fls.AcceptedFileTypes = new string[] { ".pdf", ".jpg", ".jpeg" };
            Assert.Equal(".pdf, .jpg, .jpeg", fls.AcctptedFileTypesAsString);
        }
Exemplo n.º 2
0
        public void TestFileAllowed()
        {
            var fls = new FileLoading();

            fls.AcceptedFileTypes = new string[] { ".pdf", ".jpg", ".jpeg" };
            Assert.False(fls.isAcceptedFileType("SomeFile.xml"));
            Assert.True(fls.isAcceptedFileType("AnotherFile.jpg"));
        }
Exemplo n.º 3
0
 public FilesController(
     IUnitOfWork unitOfWork,
     IFileRepository repository,
     IUserRepository userRepo,
     IMapper mapper,
     IHostingEnvironment hostEnv,
     IOptionsSnapshot <FileLoading> flOptions
     )
 {
     this._repository = repository;
     this._userRepo   = userRepo;
     this._mapper     = mapper;
     this._hostEnv    = hostEnv;
     this._flSettings = flOptions.Value;
     this._unitOfWork = unitOfWork;
 }
Exemplo n.º 4
0
        public async Task <MediaStatus> LoadAsync(
            MediaInformation media,
            bool autoPlay        = true,
            double seekedSeconds = 0,
            params int[] activeTrackIds)
        {
            _logger.LogInfo($"{nameof(LoadAsync)}: Trying to load media = {media.ContentId}");
            CurrentContentId = null;
            CancelAndSetListenerToken();

            FileLoading?.Invoke(this, EventArgs.Empty);

            var app = await _receiverChannel.GetApplication(_sender, _connectionChannel, _mediaChannel.Namespace);

            var status = await _mediaChannel.LoadAsync(_sender, app.SessionId, media, autoPlay, activeTrackIds);

            if (status is null)
            {
                LoadFailed?.Invoke(this, EventArgs.Empty);
                _logger.LogWarn($"{nameof(LoadAsync)}: Couldn't load media {media.ContentId}");
                return(null);
            }

            CurrentContentId     = media.ContentId;
            CurrentMediaDuration = media.Duration ?? status?.Media?.Duration ?? 0;
            CurrentVolumeLevel   = status?.Volume?.Level ?? 0;
            IsMuted        = status?.Volume?.IsMuted ?? false;
            ElapsedSeconds = 0;
            _seekedSeconds = seekedSeconds;

            TriggerTimeEvents();
            IsPlaying = true;
            IsPaused  = false;
            ListenForMediaChanges(_listenerToken.Token);
            ListenForReceiverChanges(_listenerToken.Token);

            FileLoaded?.Invoke(this, EventArgs.Empty);
            _logger.LogInfo($"{nameof(LoadAsync)}: Media = {media.ContentId} was loaded. Duration = {CurrentMediaDuration} - SeekSeconds = {_seekedSeconds}");
            return(status);
        }