NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 36 37 38 39 40 … 93 Next »
GBPVRUIElement - updating frequently

 
  • 0 Vote(s) - 0 Average
GBPVRUIElement - updating frequently
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#1
2008-01-04, 04:20 AM
Hi, got a GBPVRUiElement I want updated frequently to keep up with a song playing.

For a screen saver, that will contain album art, song title and the place within the song.

I can get it all displaying, but I'm hitting the GetRenderList quite frequently.

I don't really want to re-create the UIElement all the time. I can keep track of which song it is and only re-make the image when the track changes, but are there any nice ways of updating a string. If i have to, I'll create the text as a separate element.

Code:
if (args == null)
    args = new System.Collections.Hashtable();

    args.Clear();
    args["@ArtistSong"] = media.Artist + "-" + media.Title;
    args["@Time"] = currentSong.ToString();
    args["@AlbumArt"] = media.GetImage();

    Image playingImage = skinHelper.getNamedImage("Playing", args);
    uiElement = new GBPVR.Public.GBPVRUiElement("Playing", skinHelper.getPlacementRect("Playing"), playingImage);                                        
    items.Add(uiElement);
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#2
2008-01-04, 04:35 AM
declare a member variable for a UiStatic:
Code:
private UiStatic nowPlayingStatic = null;
create it in your one-time initialisation function:
Code:
Hashtable args = new Hashtable();
args["@ArtistSong"] = "";
args["@Time"] = "";
args["@AlbumArt"] = "";
nowPlayingStatic = new UiStatic(skinHelper2, "Playing", args);

In your GetRenderList() function, let the UIStatic know what the current parameters are, then add it to the render list. It'll take care of only refreshing the GBPVRUiElement when it needs to be (redrawing the "Playing" composite image etc).

Code:
Hashtable args = new Hashtable();
args["@ArtistSong"] = media.Artist + "-" + media.Title;
args["@Time"] = currentSong.ToString();
args["@AlbumArt"] = media.GetImage();
nowPlayingStatic.SetArgs(args);

...
ArrayList renderList = new ArrayList()
... add other stuff to the render list.
renderList.AddRange(nowPlayingStatic.GetRenderList());

Let me know if you have problems.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#3
2008-01-04, 05:01 AM
Seems to work, but I'm using a lot of cpu.


If I track is playing then I'm pretty much always returning true from needsRendering.

I've pretty much done what you had.

Created the UiStatic, set it to nothing to start.

ok, been playing while writing this, and turned off the needsRendering. I get the cpu back and can use the keyboard. Did I remember correctly that with pxrx2 you look at needs rendering more often? as in not every second?

So for something like this that I want updated fairly regularly, what would you recommend? A timer to set needsRendering as true every second? Or is there another way I should do it?
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#4
2008-01-04, 05:07 AM
Don't worry, figured it out. Put a check in the needsRendering to see if it updated less that a second ago, if yes return false, otherwise, return true.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#5
2008-01-04, 05:56 AM
You can have your needsRendering() method setting the args, then calling needsRendering() on the UiStatic.

Code:
Hashtable args = new Hashtable();
args["@ArtistSong"] = media.Artist + "-" + media.Title;
args["@Time"] = currentSong.ToString();
args["@AlbumArt"] = media.GetImage();
nowPlayingStatic.SetArgs(args);

if (nowPlayingStatic.needsRendering())
    return true;
...

The UiStatic needsRendering() method will return 'true' if the image has been updated and needs to be redrawn on the screen.

Quote:ok, been playing while writing this, and turned off the needsRendering. I get the cpu back and can use the keyboard. Did I remember correctly that with pxrx2 you look at needs rendering more often? as in not every second?
Yes, its called very frequently for plugins that implement IUiTask, to allow for animations etc.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#6
2008-01-04, 10:00 AM
sub Wrote:You can have your needsRendering() method setting the args, then calling needsRendering() on the UiStatic.

That's what I was missing (from the other thread).

Thanks sub.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#7
2008-01-04, 10:16 AM
Have a look at the dvd ripper sample plugin from sub, where he does this.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  updating EPG reven 3 2,070 2012-11-30, 09:05 PM
Last Post: reven
  Updating images scb147 11 4,525 2010-07-30, 06:11 PM
Last Post: scb147
  Freeing up GBPVRUiElement's InVermont 0 1,122 2009-01-22, 01:44 AM
Last Post: InVermont
  GBPVRUiElement loose its alpha herrmannj 3 1,620 2008-11-11, 05:13 PM
Last Post: sub
  Scrollable GBPVRUIElement ? lupus11 7 2,638 2008-02-12, 04:26 PM
Last Post: JavaWiz
  Texture locations of GBPVRUiElement on MVP alibert 2 1,527 2007-10-02, 04:29 AM
Last Post: alibert
  @time and @date not updating Digital712 3 2,113 2006-08-23, 02:06 AM
Last Post: Fatman_do
  updating a database reven 2 1,628 2005-02-08, 08:19 AM
Last Post: reven

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

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

Linear Mode
Threaded Mode