Exemplo n.º 1
0
        protected override async Task <int> OnExecute(CommandLineApplication app)
        {
            try
            {
                if (!WebServerUtils.IsServerAlive())
                {
                    _console.WriteLine("Server is not running");
                    return(-1);
                }

                var url = ServerUtils.StartServerIfNotStarted(_console);
                if (string.IsNullOrWhiteSpace(url))
                {
                    return(-1);
                }

                bool isLocal = _fileService.IsLocalFile(Mrl);
                if (!_fileService.Exists(Mrl))
                {
                    _console.WriteLine($"File = {Mrl} does not exist");
                    return(-1);
                }

                _console.WriteLine($"Trying to play file = {Mrl}...");
                var request = isLocal
                    ? PlayCliFileRequestDto.FromLocal(Mrl, VideoStreamIndex, AudioStreamIndex, SubsStreamIndex)
                    : PlayCliFileRequestDto.FromYoutube(Mrl, Quality);

                if (Seconds > 0)
                {
                    request.Seconds = Seconds;
                }

                _console.WriteLine(
                    $"The following request will be send to the api = {JsonConvert.SerializeObject(request, Formatting.Indented)}, " +
                    $"the server url is = {url}");
                var castItApi = RestService.For <ICastItApi>(url);
                var response  = await castItApi.Play(request);

                _console.WriteLine(response.Succeed
                    ? $"File = {Mrl} was successfully loaded"
                    : $"File couldn't be loaded. Error = {response.Message}");
            }
            catch (Exception e)
            {
                _console.WriteLine(e.ToString());
                return(-1);
            }
            return(await base.OnExecute(app));
        }
Exemplo n.º 2
0
 public Task StartPlay(PlayCliFileRequestDto request, FFProbeFileInfo fileInfo)
 => StartPlay(request.Mrl, request.VideoStreamIndex, request.AudioStreamIndex, request.SubtitleStreamIndex, request.Quality, fileInfo, request.Seconds);
Exemplo n.º 3
0
 public Task GoToSeconds(PlayCliFileRequestDto request, FFProbeFileInfo fileInfo)
 => GoToSeconds(request.VideoStreamIndex, request.AudioStreamIndex, request.SubtitleStreamIndex, request.Quality, request.Seconds, fileInfo);