NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 23 24 25 26 27 … 93 Next »
Plugin notification of stopped media

 
  • 0 Vote(s) - 0 Average
Plugin notification of stopped media
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,847
Threads: 954
Joined: May 2006
#1
2009-08-19, 04:03 AM
Is any message sent back to a plugin when media is stopped outside of the plugin or while the plugin is in screen saver mode? If not is there a way to add an event handler to PluginHelperFactory where I could do some clean up code?

Martin
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,666
Threads: 767
Joined: Nov 2003
#2
2009-08-19, 04:17 AM
If you plugin implements the GBPVR.Public.IEventNotification interface, then it'll automatically be sent events whenever they happen. (ie, the Notify() method will get called whenever music/videos/dvds start or stop)
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,847
Threads: 954
Joined: May 2006
#3
2009-08-19, 04:55 AM
Yes thanks that got me in the right direction and found this thread I should have found http://forums.nextpvr.com/showthread.php?t=17255

Martin
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,847
Threads: 954
Joined: May 2006
#4
2009-08-19, 04:48 PM
I'm still having problems understanding this, does the Notify() event inherit a different instance?

I have

namespace WebRadio
{
public class WebRadio : BaseButtonListUiTask, SkinHelper2.GetImageCallback, IUiTask, IEventNotification
{
protected bool flag = false;
...

This flag is different in the Notify() event then in the plugin derived class

Martin
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,666
Threads: 767
Joined: Nov 2003
#5
2009-08-19, 05:12 PM
Yes, it'll be a different instance of the class than your main plugin (for historic reasons, and unable to be changed now without breaking things). It was originally intended that people would not put this interface on their actual plugin class.

You could do something like this. Create a sparate class for receiving notifications, which effectively just forwards events to your main plugin.

Code:
namespace WebRadio
{
public class EventNotification:  IEventNotification
...
void Notify(EventTypes eventType, string eventText)
{
    WebRadio.GetInstance().Notify(eventType, eventText);
}
...

Then setup the singleton on your main WebRadio class
Code:
namespace WebRadio
{
public class WebRadio : BaseButtonListUiTask, SkinHelper2.GetImageCallback, IUiTask, IEventNotification
{
private static WebRadio singleton;

// in the constructor, set the single to the instance
public WebRadio()
{
    ...
    singleton = this;
    ...
}

// provide a method to get the singleton
public WebRadio GetInstance()
{
    return singleton;
}

// method to handle events in your plugin
void Notify(EventTypes eventType, string eventText)
{
    ....
}
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,847
Threads: 954
Joined: May 2006
#6
2009-08-19, 09:33 PM
Thanks sub, that looks easy enough, singletons might not pass muster at work but I trust GBPVR.

Martin
sub
Online

Administrator

NextPVR HQ, New Zealand
Posts: 106,666
Threads: 767
Joined: Nov 2003
#7
2009-08-19, 09:43 PM
While there are other ways of achieving the same results, using a singleton was a nice compact way of describing a solution, and entirely appropriate in this type of situation.

If it was a web app or some highly parallel code, with the potential for contention on shared resources, I might not advise the same thing, but thats not the case here...
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,847
Threads: 954
Joined: May 2006
#8
2009-08-19, 11:16 PM
Thanks sub, it works, like a treat except it wanted

public <b>static</b> WebRadio GetInstance()

BTW, I hope you understand that my comment was not supposed to be negative I know you wouldn't lead me astray. In any case there is a reason that enterprise programmers can be happy with 50 lines of code a day, which I will never understand.

Martin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 2,782 2022-10-17, 12:44 AM
Last Post: sgilani
  New Systems Plugin kirschey 10 3,325 2020-11-14, 08:01 PM
Last Post: sub
  Looking for C# UPnP Media Server code bgowland 5 7,580 2016-12-16, 08:25 PM
Last Post: mvallevand
  Media Browser Integration lukemb3 557 149,527 2015-11-29, 05:27 PM
Last Post: UncleJohnsBand
  VIdeo playback from plugin mvallevand 5 3,438 2015-08-06, 10:43 PM
Last Post: sub
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 2,879 2014-11-14, 02:05 AM
Last Post: Benoire
  Media\Show Directory mvallevand 12 6,017 2014-07-02, 10:58 AM
Last Post: sub
  API docs to help with plugin development? McBainUK 3 2,755 2013-06-08, 06:14 PM
Last Post: sub
  Media\Shows Metadata mvallevand 2 1,840 2013-05-22, 04:09 AM
Last Post: mvallevand
  Refreshing TV Guide Data (after System plugin EPG update) imilne 13 6,053 2013-03-24, 08:03 PM
Last Post: imilne

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode