Created
July 9, 2014 15:16
-
-
Save rcurtis/c78d5f33b9fe9f0ef66e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MotionNET; | |
using SFML.Graphics; | |
using SFML.Window; | |
namespace MotionTest | |
{ | |
class Program | |
{ | |
private RenderWindow window; | |
private DataSource dataSource; | |
private VideoPlayback videoPlayback; | |
private AudioPlayback audioPlayback; | |
private bool playing; | |
public Program() | |
{ | |
window = new RenderWindow(new VideoMode(1280, 800), "Motion test"); | |
window.SetVerticalSyncEnabled(true); | |
dataSource = new DataSource(); | |
if (!dataSource.LoadFromFile("jetBot.mov")) | |
{ | |
Console.WriteLine("Could not load video"); | |
} | |
videoPlayback = new VideoPlayback(dataSource, Color.Transparent); | |
audioPlayback = new AudioPlayback(dataSource); | |
dataSource.EndofFileReached += HandleEndOfFile; | |
window.Closed += (sender, e) => window.Close(); | |
window.MouseButtonPressed += (sender, args) => | |
{ | |
playing = true; | |
dataSource.Play(); | |
}; | |
while (window.IsOpen) | |
{ | |
window.DispatchEvents(); | |
window.Clear(); | |
if (playing) | |
{ | |
dataSource.Update(); | |
window.Draw(videoPlayback); | |
} | |
window.Display(); | |
} | |
} | |
private void HandleEndOfFile(DataSource obj) | |
{ | |
playing = false; | |
audioPlayback.Dispose(); | |
videoPlayback.Dispose(); | |
dataSource.EndofFileReached -= HandleEndOfFile; | |
dataSource.Dispose(); | |
} | |
static void Main(string[] args) | |
{ | |
Program program = new Program(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment