コード例 #1
0
        private async Task <AVideoEntity> CreateVideo(FileInfo file)
        {
            AVideoEntity video = await videoService.FindByNameAsync(file.DirectoryName, file.Name);

            if (video != null)
            {
                Console.WriteLine("文件已存在...");

                return(video);
            }

            video = new AVideoEntity();

            video.Path = file.DirectoryName;
            video.Name = file.Name;

            video.Producer = "";
            video.Title    = AnimeUtils.ParseTitle(video.Name);
            video.Language = "ja";

            video.Length = file.Length;

            video.XInsert_ = file.CreationTime;
            video.XUpdate_ = file.LastWriteTime;

            video = await videoService.SaveAsync(video);

            return(video);
        }
コード例 #2
0
        protected override async Task OnInitializedAsync()
        {
            videoId = base.Options;

            videoEntity = await videoService.FindAsync(videoId);

            await base.OnInitializedAsync();
        }
コード例 #3
0
ファイル: Edit.razor.cs プロジェクト: anyonetff/HentaiBlazor
        protected override async Task OnInitializedAsync()
        {
            videoId = base.Options ?? null;

            if (StringUtils.IsBlank(videoId))
            {
                videoEntity = new AVideoEntity();
            }
            else
            {
                videoEntity = await videoService.FindCloneAsync(videoId);
            }

            await base.OnInitializedAsync();
        }
コード例 #4
0
        public async Task Playback(string id)
        {
            Console.WriteLine("开始播放视频文件[" + id + "].");

            AVideoEntity video = await videoService.FindAsync(id);

            if (video == null)
            {
                return;
            }

            using (Stream stream = this.Response.BodyWriter.AsStream())
            {
                await WriteToStream(stream, Path.Combine(video.Path, video.Name));
            }
        }
コード例 #5
0
        public async Task Preview(string id)
        {
            byte[] preview = previewService.GetCached(id);

            if (preview == null)
            {
                AVideoEntity video = await videoService.FindAsync(id);

                preview = await previewService.GetAsync(video);
            }

            using (Stream stream = this.Response.BodyWriter.AsStream())
            {
                await stream.WriteAsync(preview, 0, preview.Length);
            }
        }
コード例 #6
0
        public async Task <byte[]> GetAsync(AVideoEntity video)
        {
            //lock(this);

            if (cache.ContainsKey(video.Id))
            {
                return(cache[video.Id]);
            }
            //string cover = "";

            byte[] c = none;

            lock (this)
            {
                c = ReadAsync(Path.Combine(video.Path, video.Name));
                cache.Add(video.Id, c);
            }

            return(c);
        }
コード例 #7
0
        private async Task DiscoveryAnime(string path, bool children)
        {
            DirectoryInfo root = new DirectoryInfo(path);

            if (!root.Exists)
            {
                Console.WriteLine("目录不存在");
                // 文件目录不存在
                // TODO: 这里应该有个报警.
                return;
            }

            if (children)
            {
                DirectoryInfo[] dirs = root.GetDirectories();

                foreach (var dir in dirs)
                {
                    await DiscoveryAnime(dir.FullName, children);
                }
            }

            FileInfo[] files = root.GetFiles();

            foreach (var file in files)
            {
                if (!AnimeUtils.IsMedia(file.Name))
                {
                    // 如果当前文件不是视频档案
                    continue;
                }

                AVideoEntity video = await CreateVideo(file);

                //BAuthorEntity author = await CreateAuthor(book.Author);
            }
        }
コード例 #8
0
        protected override async Task OnInitializedAsync()
        {
            Console.WriteLine("打开视频详情");

            video = await videoService.FindAsync(Id);
        }