Ejemplo n.º 1
0
        public void Play()
        {
            var result = ShellRunner.ExecuteShellCommand("./dbuscontrol.sh", "play", 10000)
                         .GetAwaiter()
                         .GetResult();

            if (result.ExitCode == 0)
            {
                log.Debug("play");
                return;
            }

            log.Warn("Can not run play command. Code: {0}. Out: {1}", result.ExitCode, result.Output);
        }
Ejemplo n.º 2
0
        public void Next()
        {
            var result = ShellRunner.ExecuteShellCommand("./dbuscontrol.sh", ">", 10000)
                         .GetAwaiter()
                         .GetResult();

            if (result.ExitCode == 0)
            {
                log.Debug(nameof(Next));
                return;
            }

            log.Warn("Can not run 'next' command. Code: {0}. Out: {1}", result.ExitCode, result.Output);
        }
Ejemplo n.º 3
0
        public async Task <MediaContent> GetMediaContent(Uri url)
        {
            var source = url.ToString();
            var result = await ShellRunner.ExecuteShellCommand(
                "youtube-dl",
                $"-e --get-duration -g -f best {source}", 30000);

            if (result.ExitCode != 0)
            {
                throw new Exception($"Failed to load content. {result.Output}");
            }

            var lines = result.Output.Split("\n");
            var info  = new MediaContent();

            info.Title    = lines[0];
            info.Source   = new Uri(lines[1]);
            info.Duration = lines.Last();

            return(info);
        }