Wiki Navigation
- Loading...
In your own plugin you can receive events from the TV-Server when it performs actions. Such an action might be that the server is about to change the TV channel for example or start recording. Your plugin can receive such events and react on them.
For example you might build a plugin which controls an external settopbox to tune to the correct channel just before the server is tuning to it. So how do we use events?
First build a plugin as explained on the TV-Server Plugins page.
Next, you need to subscribe to the event handler which is done like this:
/// <summary> /// Starts the plugin /// </summary> void Start(IController controller) { ITvServerEvent events = GlobalServiceProvider.Instance.Get<ITvServerEvent>(); events.OnTvServerEvent += new TvServerEventHandler(events_OnTvServerEvent); } /// <summary> /// Stops the plugin /// </summary> void Stop() { ITvServerEvent events = GlobalServiceProvider.Instance.Get<ITvServerEvent>(); events.OnTvServerEvent -= new TvServerEventHandler(events_OnTvServerEvent); } /// <summary> /// Handles the OnTvServerEvent event fired by the server. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="eventArgs">The <see cref="System.EventArgs"/> the event data.</param> void events_OnTvServerEvent(object sender, EventArgs eventArgs) { TvServerEventArgs tvEvent=(TvServerEventArgs)eventArgs; switch(tvEvent.EventType) { ///StartZapChannel is called just before the server is going to change channels case TvServerEventType.StartZapChannel: break; ///EndZapChannel is called after the server changed channels case TvServerEventType.EndZapChannel: break; ///StartRecording is called just before the server is going to start recording case TvServerEventType.StartRecording: break; ///RecordingStarted is called when the recording is started case TvServerEventType.RecordingStarted: break; ///RecordingEnded is called when the recording has been stopped case TvServerEventType.RecordingEnded: break; }
The OnTvServerEvent() will be called when the server performs several tasks.
It is safe to cast the eventArgs supplied to the derived class TvServerEventArgs
The TvServerEventArgs exposes several properties:
IController Controller { get; }
Returns a reference to the IController interface of the server
User User { get; }
Returns a reference to the user responsible for this action
VirtualCard Card { get; }
Returns a reference to the card for which the action was performed
IChannel channel { get; }
Returns a reference to the channel on which the action was performed
IChannel channel { get; }
Returns a reference to the channel on which the action was performed
Recording Recording { get; }
Returns a reference to the recording
Schedule Schedule { get; }
Returns a reference to the schedule used for the recording
TvServerEventType EventType { get; }
Returns the event type
This page has no comments.