Results 1 to 8 of 8

Thread: Random API questions

  1. #1
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716

    Random API questions

    1. What's the difference between SettingsHelper.SetSetting() and SettingsHelper.SetOverride()?
    2. Is there a way to monitor and intercept/override keypresses? I would like to intercept keys while playing video and override the default behaviour but implimenting IScreenPlugin will only fire OnKeyDown() if the plugin is active and OnKeyPress() never seems to be fired when implementing IKeyPress.
    3. If I want to display my own subtitles on videos (non .ts files), can I just call Native.UpdateCCBitmap() or do I need to implement ICCSubtitleData. If the latter, how would I do that? I see SetSubtitleStream() but not a SetSubtitlePlugin()


    I do realize that the answer for 2 and 3 is probably "It wasn't meant to do this".

  2. #2
    Join Date
    Nov 2003
    Location
    NextPVR HQ, Wellington, New Zealand
    Posts
    76,110
    1.What's the difference between SettingsHelper.SetSetting() and SettingsHelper.SetOverride()?
    It not intended that developers use SetOverride(). It was only added as a workaround for a complicated circular problem I created for myself.

    2.Is there a way to monitor and intercept/override keypresses? I would like to intercept keys while playing video and override the default behaviour but implimenting IScreenPlugin will only fire OnKeyDown() if the plugin is active and OnKeyPress() never seems to be fired when implementing IKeyPress.
    If your plugin is listening for event bus notifications, it'll get the PLAYBACK_KEYDOWN event, where "args" is a KeyEventArgs object.

    3.If I want to display my own subtitles on videos (non .ts files), can I just call Native.UpdateCCBitmap() or do I need to implement ICCSubtitleData. If the latter, how would I do that? I see SetSubtitleStream() but not a SetSubtitlePlugin()
    You'd maybe call PluginHelperFactory.GetInstance().GetPlaybackProxy ().SetOSD() passing in a renderlist of UiElement objects. In your case that renderlist would be one object, containing your bitmap.

  3. #3
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716
    Quote Originally Posted by sub View Post
    It not intended that developers use SetOverride(). It was only added as a workaround for a complicated circular problem I created for myself.
    That makes my choice easy then. I want to set <MenuItem> enabled to false when saving settings to make sure that "background" plugins don't ever appear in the menu and SetOverride() made me stop and think.

    Quote Originally Posted by sub View Post
    If your plugin is listening for event bus notifications, it'll get the PLAYBACK_KEYDOWN event, where "args" is a KeyEventArgs object.
    Doh, I missed that event somehow.

    Quote Originally Posted by sub View Post
    You'd maybe call PluginHelperFactory.GetInstance().GetPlaybackProxy ().SetOSD() passing in a renderlist of UiElement objects. In your case that renderlist would be one object, containing your bitmap.
    One of these days I will have to learn how to not make things so complicated.

  4. #4
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716
    Quote Originally Posted by sub View Post
    If your plugin is listening for event bus notifications, it'll get the PLAYBACK_KEYDOWN event, where "args" is a KeyEventArgs object.
    That worked to capture the the event but I can't override the default handling. Even if I activate my own popup, the defaults kill it and activate.

    Next time you're in that part of the code, would it be possible to get a Notify("ACTIVATE_POPUP", "SelectAudio") and Notify("ACTIVATE_POPUP", "SelectSubtitles") for videos and dvds? (I'm filtering filetypes if it is fired for all playback or none type of deal)

    I can then override it with my own popup.

  5. #5
    Join Date
    Nov 2003
    Location
    NextPVR HQ, Wellington, New Zealand
    Posts
    76,110
    I should be able to do something like that. I'm a bit busy today though.

  6. #6
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716
    There's no rush on it. I'm off to bed and not sure if I will get back to it tomorrow or not. I just figure there is not much point to assigning yet another key for existing functions just for BD playback.

  7. #7
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716
    sub, I set a delay so that my popup will render after the default popup and it serves my purpose. One thing I noticed though is that once the default audio/subtitle selection is activated, PluginHelperFactory.GetPluginHelper().GetActivePop up() still returns null. So even though I render my popup, once my popup is cleared, the default popup reappears on screen.

    I hope I'm making some sense.

    Edit: Here's my code:
    Code:
            public void Notify(string eventName, object eventArg)
            {
                if (eventName == "PLAYBACK_KEYDOWN")
                {
                    string s = new KeyCommandHelper(SettingsHelper.GetInstance().GetDataDirectory() + "KeyMappings.xml").GetCommand("VideoPlayback", (KeyEventArgs)eventArg);
                    if (s == "SelectAudio" || s == "SelectSubtitles")
                    {
                        delay = new System.Timers.Timer(1000);
                        delay.AutoReset = false;
                        delay.Elapsed += new System.Timers.ElapsedEventHandler(delay_Elapsed);
                        delay.Start();
                    }
            }
    
            void delay_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                IScreenPlugin currentPopup = PluginHelperFactory.GetPluginHelper().GetActivePopup();
                if (currentPopup != null)
                  PluginHelperFactory.GetPluginHelper().ActivatePopup(null);                         // This never gets fired because GetActivePopup always returns null even though there is a popup on screen.
                PluginHelperFactory.GetPluginHelper().ActivatePopup(new StreamPopup());
            }
    Last edited by whurlston; 2012-08-09 at 01:51 AM.

  8. #8
    Join Date
    Nov 2006
    Location
    Louisville, KY, USA
    Posts
    7,716
    End result (with a few niggles):

    And yes... the selections do actually work.
    Attached Images Attached Images   

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •