public int EventsNavHandler(NameValueCollection parameters) { using (XbmcMonitor m = new XbmcMonitor()) { m.OnScreensaverActivated += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Screensaver Activated!"); }); m.OnScreensaverDeactivated += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Screensaver Deactivated!"); }); m.OnNotification += new EventHandler <NotificationEventArgs>(delegate(object s, NotificationEventArgs ev) { Console.WriteLine(string.Format("=> Notification from {0}({1}) ==> {2}", ev.Sender, ev.Method, ev.Data)); }); Kodi.Sleep(TimeSpan.FromSeconds(1)); Console.WriteLine("Triggering screensaver"); SystemBuiltins.ActivateScreensaver(); if (!m.AbortRequested) { m.WaitForAbort(TimeSpan.FromSeconds(10)); } } return(0); }
public int AudioNavHandler(NameValueCollection parameters) { XbmcPlayer player = new XbmcPlayer(); player.PlayBackStarted += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Playback started!"); }); player.PlayBackEnded += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Playback finished!"); }); //Thread.Sleep(TimeSpan.FromSeconds(1)); player.Play("http://www.bensound.com/royalty-free-music?download=memories"); while (!player.IsPlayingAudio) { Kodi.Sleep(TimeSpan.FromSeconds(1)); } for (int i = 10; i <= 100; i += 5) { ApplicationBuiltins.SetVolume(i, true); Kodi.Sleep(TimeSpan.FromMilliseconds(200)); } /* Keep monitoring for a bit */ Kodi.Sleep(TimeSpan.FromSeconds(10)); return(0); }
public int PlaylistHandler(NameValueCollection parameters) { Uri uri = new Uri("http://www.amclassical.com/piano/"); var data = new HttpClient() .GetAsync(uri) .Result.Content .ReadAsStringAsync() .Result; PlayList pl = new PlayList(PlayListType.Music); List <ListItem> items = new List <ListItem> { }; var matches = new Regex("<a href=\"?(.*?)\"?>.*</a>").Matches(data); var number = Math.Min(5, matches.Count); for (var i = 0; i < number; i++) { string path = matches[i].Groups[1].Value.ToLower(); if (!path.EndsWith("mp3")) { continue; } string url = uri.GetLeftPart(UriPartial.Authority) + path; pl.Add(url); items.Add(new ListItem(label: Path.GetFileName(path), url: url)); } List.Add(items); List.Show(); var player = new XbmcPlayer(); player.Play(pl); for (int i = 0; i < pl.Count; i++) { while (!player.IsPlayingAudio) { Kodi.Sleep(TimeSpan.FromMilliseconds(200)); } var info = player.MusicInfoTag; Console.WriteLine($"[NOW PLAYING]: {player.PlayingFile}"); Console.WriteLine("====================="); Console.WriteLine($"{info.URL}, {info.Title}"); Kodi.Sleep(TimeSpan.FromSeconds(5)); player.PlayNext(); } return(0); }
public static void EventsNavHandler(NameValueCollection parameters) { Smx.KodiInterop.Modules.Xbmc.Monitor m = new Smx.KodiInterop.Modules.Xbmc.Monitor(); m.Notification += new EventHandler <NotificationEventArgs>(delegate(object s, NotificationEventArgs ev) { Console.WriteLine(string.Format("=> Notification from {0}({1}) ==> {2}", ev.Sender, ev.Method, ev.Data)); }); Thread.Sleep(TimeSpan.FromSeconds(1)); Console.WriteLine("Triggering screensaver"); SystemBuiltins.ActivateScreensaver(); /* Keep monitoring for a bit */ Kodi.Sleep(TimeSpan.FromSeconds(10)); }
public static void AudioNavHandler(NameValueCollection parameters) { //Player player = new Player(PyVariableManager.Player); Player player = new Player(); player.PlayBackStarted += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Playback started!"); }); player.PlayBackEnded += new EventHandler <EventArgs>(delegate(object s, EventArgs ev) { Console.WriteLine("=> Playback finished!"); }); player.Play("http://www.bensound.com/royalty-free-music?download=memories"); /* Keep monitoring for a bit */ Kodi.Sleep(TimeSpan.FromSeconds(20)); }