コード例 #1
0
    private async Task UpdateStatus(BitFileUploadStatus uploadStatus, int index)
    {
        if (Files is null)
        {
            return;
        }

        if (index < 0)
        {
            UploadStatus = uploadStatus;

            var files = Files.Where(c => c.Status != BitFileUploadStatus.NotAllowed).ToArray();
            foreach (var file in files)
            {
                file.Status = uploadStatus;
            }

            await OnChange.InvokeAsync(files);
        }
        else
        {
            if (Files[index].Status != uploadStatus)
            {
                Files[index].Status = uploadStatus;
                await OnChange.InvokeAsync(new[] { Files[index] });
            }

            if (uploadStatus == BitFileUploadStatus.InProgress)
            {
                await OnProgress.InvokeAsync(Files[index]);
            }

            if (uploadStatus == BitFileUploadStatus.Completed)
            {
                await OnUploadComplete.InvokeAsync(Files[index]);
            }

            if (uploadStatus == BitFileUploadStatus.Removed)
            {
                await OnRemoveComplete.InvokeAsync(Files[index]);
            }

            if (uploadStatus == BitFileUploadStatus.Failed)
            {
                await OnUploadFailed.InvokeAsync(Files[index]);
            }

            if (uploadStatus == BitFileUploadStatus.RemoveFailed)
            {
                await OnRemoveFailed.InvokeAsync(Files[index]);
            }
        }
    }
コード例 #2
0
        public async Task OnProgressEventHandler(string eventJson)
        {
            var eventObj = JsonSerializer.Deserialize <BulMediaProgressChangeEvent>(eventJson);

            PlayerState.BufferProgress.Clear();
            foreach (var progressItem in eventObj.Progress)
            {
                PlayerState.BufferProgress.Add(progressItem.Key, new BulMediaProgressItem()
                {
                    Index = progressItem.Value.Index,
                    Start = TimeSpan.FromSeconds(progressItem.Value.Start),
                    End   = TimeSpan.FromSeconds(progressItem.Value.End),
                });
            }

            await OnProgress.InvokeAsync(PlayerState);

            StateHasChanged();
        }