NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 28 29 30 31 32 … 93 Next »
Potentially a Very large Image list

 
  • 0 Vote(s) - 0 Average
Potentially a Very large Image list
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#1
2008-10-21, 09:05 AM
Been doing some development on ML3 where I have an album view.

The problem is, with the album view on the All all setting, i can potentially have an extremely large list where it's also trying to load the images for each track.

On my system it fell over at 2000 items with images.

I found i can not load the images and there's no problem.

My question is, if I just wanted to load the album images for the displayed "screen", ie the displayed 1 to 6 images, or on the next page 7 to 12 images.

Is there a way of knowing what the displayed page is? Or some other trick I could use. At the moment I'm potentially looking at the option of if > x number of items, don't display images.
McBainUK
Offline

Posting Freak

Posts: 4,711
Threads: 429
Joined: Sep 2005
#2
2008-10-21, 10:46 AM
Isn't there a getimage() call back in the list or list item classes. Probably worth a forum search.

(sorry can't be more specific - this post is all from memory)
Wiki profile
My Projects
Programs Plugin [SIZE=2](retired)
| Volume OSD Plugin (retired) | Documentation Wiki (retired)
[/SIZE]
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#3
2008-10-21, 02:49 PM
McBainUK Wrote:Isn't there a getimage() call back in the list or list item classes. Probably worth a forum search.

(sorry can't be more specific - this post is all from memory)
Yes, the list item supports a getImage() callback method. GBPVR will call getImage() for each visible item in the list. It also has some caching logic built in to manage the loaded images.

This way, you don't have to store all the images in memory, the callback will only be called when the image needs to be displayed, and the cache will manage the number of images in memory.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#4
2008-10-21, 02:56 PM
I ran into the same problem with my Netflix plugin. I wrote some code that will only load 15 thumbnails (selected item +/- 7) and 1 large poster (selected item). I'll send it to you later if you want.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#5
2008-10-21, 06:57 PM
That'd be great whurlston. Do you use Javawiz's tools or have rolled your own??

Email address is in my profile.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#6
2008-10-21, 07:44 PM
I don't use the WizTools utilities. I do use GBPVRCommonUtilities but only for config (and maybe logging) info.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#7
2008-10-21, 07:56 PM
Ok, I don't use anything, means I don't have to worry about compatibilities with someone elses software - I cause myself enough problems!!
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#8
2008-10-21, 10:20 PM
It's actually 24 images I load. You will need a global variable for your current UI list called "CurrentList" but you can modify to suit. You will of course need to change a couple of things like the
Code:
Netflix.WatchNow.Movie movie = allmovies.GetMovieByID((long)item.properties["@movieid"], false, false);

Here's the C# code. Then you just call LoadPosters() as the first line in GetRenderList().

Code:
private void LoadPosters()
        {
            // Check to make sure the current UIList is not empy
            if (CurrentList != null && CurrentList.Count > 0)
            {
                //Need to clean this string up
                string ImagesFolder = string.Format("{0}{1}\\images", GBPVR.Public.PluginHelperFactory.getPluginHelper().GetSkinRootDirectory().Replace("\\skin\\", "\\Skin2\\"), getSkinSubdirectory());
                
                // Set the range from the selected item
                // This is the number of items displayed +/- 1 page.
                int mean = uiList.getSelectedItemIndex();
                int min = mean - 11;
                int max = mean + 12;
                
                // Create a list of the indexes in the range.
                List<int> visible = new List<int>();
                for (int x = min; x < max; x++) if (x > -1 && x < CurrentList.Count) visible.Add(x);
                
                // Go through the current UIList and set/clear hashed values to keep memory usage at a minimum.
                for (int x = 0; x < CurrentList.Count; x++)
                {
                    UiList.Item item = (UiList.Item)CurrentList[x];
                    
                    // A single hashed value unique to each item so I know what information I need.                    
                    Netflix.WatchNow.Movie movie = allmovies.GetMovieByID((long)item.properties["@movieid"], false, false);
                    
                    // Check if the item's index is in the range.
                    if (visible.Contains(x))
                    {
                        string scImage = string.Format("{0}\\stars\\{1:0.0}.png", ImagesFolder, movie.StarClarity);
                        string rtImage = string.Format("{0}\\ratings\\{1}.gif", ImagesFolder, movie.Rating.ToString());
                        item.properties["@description"] = Netflix.CommonUtils.ReplaceCharacters(movie.Description);
                        item.properties["@starclarityimg"] = Image.FromFile(scImage);
                        item.properties["@ratingimg"] = Image.FromFile(rtImage);
                        FileInfo thumbInfo = new FileInfo(string.Format("{0}Small\\{1}.jpg", PosterFolder, movie.ID));
                        if (thumbInfo.Exists && thumbInfo.Length > 0)
                        {
                            if (!(bool)item.properties["@thumbLoaded"])
                            {
                                try
                                {
                                    item.properties["@thumbnail"] = Image.FromFile(thumbInfo.FullName);
                                    item.properties["@thumbLoaded"] = true;
                                }
                                catch (Exception e)
                                {
                                    // log the error.
                                }
                            }
                        }
                        else
                        {
                            item.properties["@thumbnail"] = NoPosterSmall;
                            item.properties["@thumbLoaded"] = false;
                        }
                        
                        // Only load large poster if using filmstrip mode
                        if (x == mean && uiList.getViewMode() == UiList.ViewMode.MODE_FILMSTRIP)
                        {
                            FileInfo posterInfo = new FileInfo(string.Format("{0}Large\\{1}.jpg", PosterFolder, movie.ID));
                            
                            // This region is only needed if you are download downloading posters in the background.
                            #region Support Poster Download
                            if (posterInfo.Exists && posterInfo.Length > 0)
                            {
                                if ((Image)item.properties["@poster"] == NoPosterLarge || (Image)item.properties["@poster"] == null) item.properties["@poster"] = Image.FromFile(posterInfo.FullName);
                            }
                            #endregion
                            else if (thumbInfo.Exists && thumbInfo.Length > 0)
                            {
                                if (!(bool)item.properties["@posterLoaded"])
                                {
                                    try
                                    {
                                        item.properties["@poster"] = Image.FromFile(thumbInfo.FullName);
                                        item.properties["@posterLoaded"] = true;
                                    }
                                    catch (Exception e)
                                    {
                                        // log the error.
                                    }
                                }
                            }
                            else
                            {
                                item.properties["@poster"] = NoPosterLarge;
                                item.properties["@posterLoaded"] = false;
                            }
                        }
                        else
                        {
                            item.properties["@poster"] = null;
                            item.properties["@posterLoaded"] = false;
                        }
                    }
                    
                    // If the item is not in the display range, clear all non necessary hashed values.
                    else
                    {
                        item.properties["@description"] = string.Empty;
                        item.properties["@starclarityimg"] = null;
                        item.properties["@ratingimg"] = null;
                        item.properties["@thumbnail"] = null;
                        item.properties["@thumbLoaded"] = false;
                        item.properties["@poster"] = null;
                        item.properties["@posterLoaded"] = false;
                    }
                }
            }
        }
If you aren't overriding GetRenderList(), you will need to do so:
Code:
public override ArrayList GetRenderList()
        {
            LoadPosters();
            return base.GetRenderList();
        }
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#9
2008-10-22, 07:03 AM
So CurrentList is the full list of items to go into the UI?
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#10
2008-10-22, 07:09 AM
Sorry, CurrentList is an ArrayList of all the items. In PopulateListWidget(), I use it in uiList.setItemList().

Code:
protected override void PopulateListWidget()
        {
            if (CurrentList == null) CurrentList = new ArrayList();
            uiList.setItemList(CurrentList);
            uiList.setNoItemsMessage("No movies available.");
            if (dlPosters != null && dlPosters.IsAlive) dlPosters.Abort();
            dlPosters = null;
            if (showPosters)
            {
                InitializePosterDownload();
            }
            uiList.setViewMode(viewMode);
        }
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Channels List by Channel Group Name scJohn 1 2,858 2018-01-05, 10:45 PM
Last Post: mvallevand
  Channel List (native controller) psycik 2 3,195 2017-06-19, 09:14 AM
Last Post: psycik
  Coverart / fanart image sizes??? bgowland 3 2,358 2014-02-16, 11:50 PM
Last Post: bgowland
  Where does this image come from? bgowland 4 2,488 2013-02-13, 07:26 PM
Last Post: bgowland
  List of "IEventNotification" events? reven 8 3,587 2012-11-01, 10:56 PM
Last Post: reven
  Problem with preview image for Pending Recordings Northpole 2 2,091 2012-08-14, 02:56 AM
Last Post: Northpole
  Building a list of files in media folders (npvr Music and Videos) bgowland 2 1,973 2012-02-05, 10:29 AM
Last Post: bgowland
  FanArt & displaying a background image Jaggy 2 1,807 2012-01-31, 11:39 PM
Last Post: sub
  Update NewSyleListPlugin Button list dynamically? psycik 2 1,841 2011-12-22, 12:25 AM
Last Post: mvallevand
  Single row horizontal list in popup? cncb 4 2,307 2011-09-28, 09:48 PM
Last Post: cncb

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

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

Linear Mode
Threaded Mode