fork download
  1. public class App{
  2. private iTunesApp iTunesApp;
  3. public App(){
  4. iTunesApp = new iTunesApp();
  5. SetupCallbacks();
  6. }
  7.  
  8. private void SetupCallbacks()
  9. {
  10. iTunesApp.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler(OnPlayEvent);
  11. iTunesApp.OnPlayerStopEvent += new _IiTunesEvents_OnPlayerStopEventEventHandler(OnStopEvent);
  12. }
  13.  
  14. private void OnPlayEvent(object iTrack)
  15. {
  16. string artist = ((IITTrack)iTrack).Artist;
  17. string name = ((IITTrack)iTrack).Name;
  18.  
  19. Console.WriteLine(String.Format("Artist: {0}, Name: {1}", artist, name));
  20. }
  21.  
  22. private void OnStopEvent(object iTrack)
  23. {
  24. string artist = ((IITTrack)iTrack).Artist;
  25. string name = ((IITTrack)iTrack).Name;
  26.  
  27. Console.WriteLine(String.Format(" Stopped. Artist: {0}, Name: {1}", artist, name));
  28. }
  29.  
  30. public void Close(){
  31. iTunesApp.OnPlayerPlayEvent -= OnPlayEvent;
  32. iTunesApp.OnPlayerStopEvent -= OnStopEvent;
  33. System.Runtime.InteropServices.Marshal.ReleaseComObject(iTunesApp);
  34. }
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,8): error CS1525: Unexpected symbol `iTunesApp', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(2,7): error CS1525: Unexpected symbol `App', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(3,21): error CS1530: Keyword `new' is not allowed on namespace elements
prog.cs(3,24): error CS1525: Unexpected symbol `iTunesApp', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(7,8): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(9,36): error CS1530: Keyword `new' is not allowed on namespace elements
prog.cs(9,39): error CS1525: Unexpected symbol `_IiTunesEvents_OnPlayerPlayEventEventHandler', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(10,36): error CS1530: Keyword `new' is not allowed on namespace elements
prog.cs(10,39): error CS1525: Unexpected symbol `_IiTunesEvents_OnPlayerStopEventEventHandler', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(13,8): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(21,8): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
prog.cs(29,7): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'
Compilation failed: 12 error(s), 0 warnings
stdout
Standard output is empty