private static void Main(string[] args) { if (!VTConsole.IsSupported) { throw new NotSupportedException(); } VTConsole.Enable(); Example3(); Console.ReadKey(); }
public static void WriteHeader() { if (VTConsole.IsSupported) { VTConsole.Enable(); } using var fontStream = typeof(Consts).Assembly.GetManifestResourceStream( $"{typeof(Consts).Assembly.GetName().Name}.Fonts.big.flf" ); var font = FigletFont.Load(fontStream); var figlet = new Figlet(font); void WriteSegments((string str, Color color)[] columns)
protected override Task <int> ExecuteCommand(AboutCommand arguments) { if (VTConsole.IsSupported && !VTConsole.IsEnabled) { VTConsole.Enable(); } var assembly = typeof(AboutCommandHandler).Assembly; using var pngStream = assembly.GetManifestResourceStream( $"{typeof(AboutCommandHandler).Assembly.GetName().Name}.Images.icon-64x64.png" ); VTConsole.SetConsoleWidth80(); using var bitmap = SKBitmap.Decode(pngStream); var builder = new StringBuilder(bitmap.Width * bitmap.Height * 22); for (var j = 0; j < bitmap.Height; j = j + 2) { for (var i = 0; i < bitmap.Width; i++) { var pixel = bitmap.GetPixel(i, j); var str = VTConsole.GetColorBackgroundString(pixel.Red, pixel.Green, pixel.Blue); builder.Append(str); builder.Append(' '); } var backStr = VTConsole.GetColorBackgroundString(0, 0, 0); builder.AppendLine(backStr); } var bytes = Encoding.ASCII.GetBytes(builder.ToString()); VTConsole.WriteFast(bytes); if (VTConsole.IsSupported && VTConsole.IsEnabled) { VTConsole.Disable(); } return(Task.FromResult(0)); }
private void Execute() { VTConsole.Enable(); VTConsole.SetWindowTitle("Yate Status Monitor"); UpdateDisplay(); using (var resetEvent = new ManualResetEventSlim()) using (var client = new YateClient(Host, Port)) { Console.CancelKeyPress += (s, e) => { e.Cancel = true; resetEvent.Set(); }; client.Connect(RoleType.Global); client.Log($"start for {Environment.UserName}"); client.Watch("chan.startup", ChanUpdate); client.Watch("chan.hangup", ChanHangup); client.Watch("call.ringing", ChanUpdate); client.Watch("call.answered", ChanUpdate); client.Watch("chan.disconnected", ChanDisconnected); client.Watch("call.update", ChanUpdate); client.Watch("user.auth", UserAuth); client.Watch("user.register", UserRegister); client.Watch("user.unregister", UserUnregister); try { UpdateFromStatus(client); } catch (Exception ex) { FlashMessage("error", $"engine.status failed: {ex.Message}"); } resetEvent.Wait(); Cleanup(); } }
static void Main(string[] args) { if (!VTConsole.IsSupported) { return; } VTConsole.Enable(); Console.OutputEncoding = Encoding.UTF8; Console.WriteLine("https://github.com/009342/ConsoleVideoPlayer"); if (args.Length == 0) { return; } //video : music bool isSound = true; VideoFileReader vfr = new VideoFileReader(); WaveOut waveOut = new WaveOut(); if (args.Length == 2) { size = int.Parse(args[1]); } audioFileReader = new AudioFileReader(args[0]); MediaFoundationReader video = null; try { Console.WriteLine("오디오 정보"); Console.WriteLine("인코딩 : " + audioFileReader.WaveFormat.ToString()); Console.WriteLine("샘플레이트 : " + audioFileReader.WaveFormat.SampleRate); Console.WriteLine("채널 : " + audioFileReader.WaveFormat.Channels); Console.WriteLine("길이 :" + audioFileReader.Length); } catch (Exception e) { isSound = false; Console.WriteLine("소리를 재생할 수 없습니다."); Console.WriteLine("오류 : " + e.ToString()); } vfr.Open(args[0]); double fps = (double)vfr.FrameRateNum / (double)vfr.FrameRateDen; fps = (fps > 59) ? 30 : fps; Console.WriteLine("비디오 정보"); Console.WriteLine("코덱 정보 : " + vfr.CodecName); Console.WriteLine("초당 프레임 : " + fps.ToString()); Console.WriteLine("총 프레임 : " + vfr.FrameCount); Console.WriteLine("너비 : " + vfr.Width); Console.WriteLine("높이 : " + vfr.Height); int Count = 5; while (Count-- > 0) { Console.WriteLine(Count.ToString()); Thread.Sleep(1000); } Console.Clear(); int c_width = 189; int c_height = 50; Console.SetWindowSize( Math.Min(c_width, Console.LargestWindowWidth), Console.LargestWindowHeight); int v_width = vfr.Width; int v_height = vfr.Height; int b_width = v_width / c_width; int b_height = v_height / c_height; if (isSound) { waveOut.Init(audioFileReader); } if (isSound) { waveOut.Play(); } Bitmap bm = new Bitmap(vfr.Width, vfr.Height); Random random = new Random(); Thread videoDecoderThread = new Thread(() => { VideoDecoderThread(vfr, fps); }); Thread frameDisposerThread = new Thread(() => { FrameDisposerThread(vfr); }); videoDecoderThread.Start(); frameDisposerThread.Start(); bool EOF = false; int tempIndex = 0; for (; ;) { while (Frames.Count < (int)((audioFileReader.CurrentTime.TotalMilliseconds / 1000) * fps) + healthy) { if (vfr.CurrentFrame + 1 == vfr.FrameCount) { EOF = true; break; } Thread.Sleep(10); Console.Title = "패스 : " + vfr.CurrentFrame.ToString() + "/" + ((audioFileReader.CurrentTime.TotalMilliseconds / 1000) * fps).ToString(); } if (EOF) { break; } tempIndex = (int)((audioFileReader.CurrentTime.TotalMilliseconds / 1000) * fps); bm = Frames[tempIndex]; if (bm == null) { break; } Console.Title = "현재 프레임 : " + vfr.CurrentFrame.ToString() + " 제거된 프레임 : " + disposedFrame + " 시간 : " + ((audioFileReader.CurrentTime.TotalMilliseconds / 1000)).ToString() + "초당 프레임 : " + fps.ToString(); Console.SetCursorPosition(0, 0); //Console.Title = "콘솔 출력중..."; ConsoleWriteImage2(bm); //Console.Title = "콘솔 출력 완료..."; SetCurrentFrame(tempIndex); } vfr.Close(); if (isSound) { video.Close(); } videoDecoderThread.Abort(); frameDisposerThread.Abort(); }