private void Image_MouseDown(object sender, MouseButtonEventArgs e) { string error = string.Empty; try { string[] files = Directory.GetFiles(Global.VideoAddress); } catch (Exception ex) { error = ex.Message; MessageBox.Show("视频存储路径不正确!", "操作提示"); } finally { if (error.Equals(string.Empty)) { Global.IsPlayer = true; _video = new VideoPlayback(); _video.Show(); } } }
public void StartSFMLProgram() { Text _songTitle = new Text(new string(new char[] { '\u4EBA', '\u4F11' }), _font); Text _songArtist = new Text(new string(new char[] { '\u4EBA', '\u4F11' }), _font); StreamReader sr = new StreamReader("./dtx/mstr.dtx", Encoding.GetEncoding(932)); string data = sr.ReadLine(); while (data != null) { if (data.StartsWith("#TITLE: ")) { _songTitle.DisplayedString = data.Substring(8); } if (data.StartsWith("#ARTIST: ")) { _songArtist.DisplayedString = data.Substring(9); break; } data = sr.ReadLine(); } _songTitle.CharacterSize = 24; _songTitle.Color = new Color(0, 255, 0); _songTitle.Font = _font; _songTitle.Position = new Vector2f(925.0f, 600.0f); _songArtist.CharacterSize = 24; _songArtist.Color = new Color(0, 255, 0); _songArtist.Font = _font; _songArtist.Position = new Vector2f(925.0f, 625.0f); Console.Write(_songTitle.DisplayedString + '\n'); Console.Write(_songArtist.DisplayedString + '\n'); Sprite _songJacketSprite = new Sprite(_songJacketTexture); _songJacketSprite.Position = new Vector2f(915.0f, 400.0f); _songJacketSprite.Rotation = -30.0f; _songJacketSprite.Scale = new Vector2f(245.0f / _songJacketTexture.Size.X, 245.0f / _songJacketTexture.Size.Y); Sprite _drumLanesSprite = new Sprite(_drumLanesTexture); _drumLanesSprite.Position = new Vector2f(350.0f, 0); if (!_video.LoadFromFile("./dtx/bg.avi")) // load a file into the data source { return; } //AudioPlayback audioplayback = new AudioPlayback(_video); // create an audio playback from our data source VideoPlayback videoplayback = new VideoPlayback(_video); // create a video playback from our data source // scale video to fit the window videoplayback.Scale = new Vector2f(1280f / (float)_video.VideoSize.X, 720f / (float)_video.VideoSize.Y); _window = new RenderWindow(new VideoMode(1280, 720), "SFML window"); _window.SetVisible(true); _window.Closed += new EventHandler(OnClosed); _bgm.Play(); while (_window.IsOpen) { _window.DispatchEvents(); _video.Update(); // update the data source - this is required for any playbacks _window.Draw(videoplayback); // draw the video playback _window.Draw(_songJacketSprite); _window.Draw(_songTitle); _window.Draw(_songArtist); _window.Draw(_drumLanesSprite); _window.Display(); _video.Play(); } }
private void parseMessage(string message) { string type = JObject.Parse(message).SelectToken("type")?.ToString(); switch (type.ToLower()) { case "response": Models.PubSub.Responses.Response resp = new Models.PubSub.Responses.Response(message); if (previousRequest != null && previousRequest.Nonce.ToLower() == resp.Nonce.ToLower()) { OnListenResponse?.Invoke(this, new OnListenResponseArgs { Response = resp, Topic = previousRequest.Topic, Successful = resp.Successful }); return; } break; case "message": Models.PubSub.Responses.Message msg = new Models.PubSub.Responses.Message(message); switch (msg.Topic.Split('.')[0]) { case "whispers": Whisper whisper = (Whisper)msg.messageData; OnWhisper?.Invoke(this, new OnWhisperArgs { Whisper = whisper }); return; case "chat_moderator_actions": ChatModeratorActions cMA = (ChatModeratorActions)msg.messageData; string reason = ""; switch (cMA.ModerationAction.ToLower()) { case "timeout": if (cMA.Args.Count > 2) { reason = cMA.Args[2]; } OnTimeout?.Invoke(this, new OnTimeoutArgs { TimedoutBy = cMA.CreatedBy, TimedoutUser = cMA.Args[0], TimeoutDuration = TimeSpan.FromSeconds(int.Parse(cMA.Args[1])), TimeoutReason = reason }); return; case "ban": if (cMA.Args.Count > 1) { reason = cMA.Args[1]; } OnBan?.Invoke(this, new OnBanArgs { BannedBy = cMA.CreatedBy, BannedUser = cMA.Args[0], BanReason = reason }); return; case "unban": OnUnban?.Invoke(this, new OnUnbanArgs { UnbannedBy = cMA.CreatedBy, UnbannedUser = cMA.Args[0] }); return; case "untimeout": OnUntimeout?.Invoke(this, new OnUntimeoutArgs { UntimeoutedBy = cMA.CreatedBy, UntimeoutedUser = cMA.Args[0] }); return; case "host": OnHost?.Invoke(this, new OnHostArgs { HostedChannel = cMA.Args[0], Moderator = cMA.CreatedBy }); return; case "subscribers": OnSubscribersOnly?.Invoke(this, new OnSubscribersOnlyArgs { Moderator = cMA.CreatedBy }); return; case "subscribersoff": OnSubscribersOnlyOff?.Invoke(this, new OnSubscribersOnlyOffArgs { Moderator = cMA.CreatedBy }); return; case "clear": OnClear?.Invoke(this, new OnClearArgs { Moderator = cMA.CreatedBy }); return; case "emoteonly": OnEmoteOnly?.Invoke(this, new OnEmoteOnlyArgs { Moderator = cMA.CreatedBy }); return; case "emoteonlyoff": OnEmoteOnlyOff?.Invoke(this, new OnEmoteOnlyOffArgs { Moderator = cMA.CreatedBy }); return; case "r9kbeta": OnR9kBeta?.Invoke(this, new OnR9kBetaArgs { Moderator = cMA.CreatedBy }); return; case "r9kbetaoff": OnR9kBetaOff?.Invoke(this, new OnR9kBetaOffArgs { Moderator = cMA.CreatedBy }); return; } break; case "channel-bitsevents": ChannelBitsEvents cBE = (ChannelBitsEvents)msg.messageData; OnBitsReceived?.Invoke(this, new OnBitsReceivedArgs { BitsUsed = cBE.BitsUsed, ChannelId = cBE.ChannelId, ChannelName = cBE.ChannelName, ChatMessage = cBE.ChatMessage, Context = cBE.Context, Time = cBE.Time, TotalBitsUsed = cBE.TotalBitsUsed, UserId = cBE.UserId, Username = cBE.Username }); return; case "video-playback": VideoPlayback vP = (VideoPlayback)msg.messageData; switch (vP.Type) { case Enums.VideoPlaybackType.StreamDown: OnStreamDown?.Invoke(this, new OnStreamDownArgs { PlayDelay = vP.PlayDelay, ServerTime = vP.ServerTime }); return; case Enums.VideoPlaybackType.StreamUp: OnStreamUp?.Invoke(this, new OnStreamUpArgs { PlayDelay = vP.PlayDelay, ServerTime = vP.ServerTime }); return; case Enums.VideoPlaybackType.ViewCount: OnViewCount?.Invoke(this, new OnViewCountArgs { ServerTime = vP.ServerTime, Viewers = vP.Viewers }); return; } break; } break; } if (logging) { unaccountedFor(message); } }
internal static void LoadVideo(string path) { Source = new DataSource(path); Video = Source.VideoPlayback; Audio = Source.AudioPlayback; }
static void Main(string[] args) { RenderWindow window = new RenderWindow(new VideoMode(640, 480), "MotionNET Playback Example"); window.SetVerticalSyncEnabled(true); // Create some buttons to control the playback VertexArray playbutton = new VertexArray(PrimitiveType.Triangles, 3); playbutton[0] = new Vertex(new Vector2f(255, 350), Color.Green); playbutton[1] = new Vertex(new Vector2f(275, 360), Color.Green); playbutton[2] = new Vertex(new Vector2f(255, 370), Color.Green); VertexArray pausebutton = new VertexArray(PrimitiveType.Quads, 8); pausebutton[0] = new Vertex(new Vector2f(305, 350), Color.Blue); pausebutton[1] = new Vertex(new Vector2f(310, 350), Color.Blue); pausebutton[2] = new Vertex(new Vector2f(310, 370), Color.Blue); pausebutton[3] = new Vertex(new Vector2f(305, 370), Color.Blue); pausebutton[4] = new Vertex(new Vector2f(320, 350), Color.Blue); pausebutton[5] = new Vertex(new Vector2f(325, 350), Color.Blue); pausebutton[6] = new Vertex(new Vector2f(325, 370), Color.Blue); pausebutton[7] = new Vertex(new Vector2f(320, 370), Color.Blue); VertexArray stopbutton = new VertexArray(PrimitiveType.Quads, 4); stopbutton[0] = new Vertex(new Vector2f(355, 350), Color.Red); stopbutton[1] = new Vertex(new Vector2f(375, 350), Color.Red); stopbutton[2] = new Vertex(new Vector2f(375, 370), Color.Red); stopbutton[3] = new Vertex(new Vector2f(355, 370), Color.Red); DataSource datasource = new DataSource(); // create the data source from which playback will happen if (!datasource.LoadFromFile("{video file path}")) // load a file into the data source { return; } AudioPlayback audioplayback = new AudioPlayback(datasource); // create an audio playback from our data source VideoPlayback videoplayback = new VideoPlayback(datasource); // create a video playback from our data source // scale video to fit the window videoplayback.Scale = new Vector2f(640f / (float)datasource.VideoSize.X, 480f / (float)datasource.VideoSize.Y); // standard SFML.NET game loop and event handling window.Closed += (sender, e) => { window.Close(); }; window.MouseButtonPressed += (sender, e) => { Vector2f mousepos = window.MapPixelToCoords(new Vector2i(e.X, e.Y)); if (playbutton.Bounds.Contains(mousepos.X, mousepos.Y)) { datasource.Play(); } else if (pausebutton.Bounds.Contains(mousepos.X, mousepos.Y)) { datasource.Pause(); } else if (stopbutton.Bounds.Contains(mousepos.X, mousepos.Y)) { datasource.Stop(); } }; while (window.IsOpen) { window.DispatchEvents(); datasource.Update(); // update the data source - this is required for any playbacks window.Clear(); window.Draw(videoplayback); // draw the video playback // draw the buttons window.Draw(playbutton); window.Draw(pausebutton); window.Draw(stopbutton); window.Display(); } }