예제 #1
0
파일: Form1.cs 프로젝트: kingtut666/holly
        void xbmc_ControllableEvent(object sender, IControllableEventArgs e)
        {
            //IControllable from = sender as IControllable;
            XBMCEventArgs xe = e as XBMCEventArgs;

            Device audio_src = null;
            //find all the AudioIn sources
            List<Device> devs = theWorld.ListDevicesByCaps(null, EDeviceCapabilities.Special_Audio_In);
            //find one which matches this message source
            foreach (Device d in devs)
            {
                if (xe.Name.StartsWith(d.ID)) audio_src = d;
            }
            if (audio_src == null)
            {
                Form1.updateLog("ERR: XBMC command couldn't find audio in", ELogLevel.Warning,
                    ELogType.XBMC | ELogType.Audio);
                return;
            }
            devs = theWorld.ListDevicesByCaps(audio_src.Parent, EDeviceCapabilities.Special_XBMC);
            if (devs == null || devs.Count < 1)
            {
                Form1.updateLog("ERR: couldn't identify XBMC endpoint", ELogLevel.Error,
                    ELogType.XBMC);
                return;
            }
            XBMC x = devs[0].Instance as XBMC;

            if (e.Action == "play show")
            {
                x.PlayTV(xe.uniqueID, xe.season, xe.episode, false);
            }
            else if (e.Action == "resume show")
            {
                x.PlayTV(xe.uniqueID, xe.season, xe.episode, true);
            }
            else if (e.Action == "play movie")
            {
                x.PlayMovie(xe.uniqueID, false);
            }
            else if (e.Action == "resume movie")
            {
                x.PlayMovie(xe.uniqueID, true);
            }
            else if (e.Action == "stop media")
            {
                x.Stop();
            }
            else if (e.Action == "resume media")
            {
                x.Resume();
            }
            else if (e.Action == "pause media")
            {
                x.Pause();
            }
            else if (e.Action == "play me some")
            {
                x.PlayGenre(xe.uniqueID);
            }
        }
예제 #2
0
파일: World.cs 프로젝트: kingtut666/holly
 void OnControllableEvent(IControllable from, IControllableEventArgs Event)
 {
     if (ControllableEvent != null)
     {
         ControllableEvent(from, Event);
     }
 }
예제 #3
0
파일: Form1.cs 프로젝트: kingtut666/holly
 void clk_ControllableEvent(object sender, IControllableEventArgs Event)
 {
     //TODO: Should only play in current location
     //TODO: Should play an alarm
     //IControllable from = sender as IControllable;
     if (Event.Action == "tick")
     {
         Form1.updateLog("Clock strikes", ELogLevel.Debug, ELogType.AlarmClock);
         if(!clkActions.ContainsKey(Event.Name)){
             Form1.updateLog("ERR: Unknown alarm: " + Event.Name, ELogLevel.Error, ELogType.AlarmClock);
             return;
         }
         try
         {
             List<FIFOStream> fouts = p.GetOutputStreams(null);
             if (fouts == null || fouts.Count == 0)
             {
                 Form1.updateLog("ERR: Couldn't find stream for remote: " + txtRemoteID.Text,
                     ELogLevel.Error, ELogType.AlarmClock | ELogType.Audio);
                 return;
             }
             if (clkActions[Event.Name].Item1)
             {
                 foreach (FIFOStream fout in fouts)
                 {
                     AudioOut.PlayWav(fout, @"C:\Users\ian\Desktop\chimes.wav");
                 }
             }
             if(clkActions[Event.Name].Item2) Talker.Say("", "The time is " + DateTime.Now.ToString("h m tt"));
             if (clkActions[Event.Name].Item3!="") Talker.Say("", clkActions[Event.Name].Item3);
         }
         catch (Exception e)
         {
             Form1.updateLog("ERR: Exception in clk_ControllableEvent: " + e.Message,
                 ELogLevel.Error, ELogType.AlarmClock);
             Form1.updateLog(e.StackTrace, ELogLevel.Error, ELogType.AlarmClock);
         }
     }
     else if (Event.Action == "removed")
     {
         clkActions.Remove(Event.Name);
     }
 }