Need to refresh child list

Discuss issues related to PS3 Media Server development (only for programmers)

Need to refresh child list

Postby wusucuma » Fri Mar 21, 2014 6:53 am

Hello.

We tried using methods refreshChildren() and dorefreshChildren() to refresh childlist.

But viewer didn't show anything changed.

And the server keeps client session until we restart the server, even we close client applications.

Please study our code attached below.

Thank you.

Code: Select all
public class Rook implements AdditionalFolderAtRoot, StartStopListener {

   private Map<String, ArrayList<VideoDAO>> listMap;
   private VideoSelect select;
   private VirtualFolder virtualFolder;
   private UserFolder userFolder;
   private boolean check;


   public Rook() {

      RookLog.info("creating root folder");
      
      viewItem();

   }

   public void viewItem() {
      virtualFolder = new VirtualFolder(name(), null);
      
      select = new VideoSelect();

      listMap = select.getVideo();

      Iterator<String> it = listMap.keySet().iterator();

      while (it.hasNext()) {
         String userName = (String) it.next();
         RookLog.info(userName);
         userFolder = new UserFolder(userName, listMap.get(userName));
         virtualFolder.addChild(userFolder);
         if(check){
            RookLog.info("check!!!");

            userFolder.refreshChildren();
            userFolder.reload();
            RookLog.info("end");

         }      
      }
      check = false;
   }

   @Override
   public JComponent config() {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public String name() {
      // TODO Auto-generated method stub
      return "Rook Plug";
   }

   @Override
   public void shutdown() {
      // TODO Auto-generated method stub

   }

   @Override
   public DLNAResource getChild() {
      // TODO Auto-generated method stub
      return virtualFolder;
   }

   @Override
   public void donePlaying(DLNAMediaInfo arg0, DLNAResource arg1) {
      // TODO Auto-generated method stub
      RookLog.info("done");
      check = true;
      viewItem();
   }

   @Override
   public void nowPlaying(DLNAMediaInfo arg0, DLNAResource arg1) {
      // TODO Auto-generated method stub
      RookLog.info("now");

   }

}


Code: Select all
public class UserFolder extends VirtualFolder {
   private ArrayList<VideoDAO> list;

   public UserFolder(String name, ArrayList<VideoDAO> list) {
      super(name, null);
      this.list = list;
      // TODO Auto-generated constructor stub
   }

   @Override
   public void discoverChildren() {
      // TODO Auto-generated method stub
//      RookLog.info(name);
      for (int i = 0; i < list.size(); i++) {
         VideoDAO dao = list.get(i);
         RookLog.info(dao.getName());
         addChild(new MyRealFile(dao.getFile(), dao.getUserName()));
         
      }

   }
   
   public void reload(){
      RookLog.info("reload");
      refreshChildren();
      doRefreshChildren();
   }
}

-FTAU
wusucuma
 
Posts: 5
Joined: Fri Mar 07, 2014 12:37 am

Re: Need to refresh child list

Postby taconaut » Fri Mar 21, 2014 4:36 pm

I'm not sure what you're trying to achieve. You shouldn't have to call refreshChildren() from your code.
If I remember correctly, discoverChildren() is being called when a folder is being entered for the first time and refreshChildren() is being called the subsequent times, if isRefreshNeeded() returns true.
I've got an implementation here which might help; it supports refreshing folder content. In this implementation isRefreshNeeded always returns true, and the content of the method refreshChildren might update folder content if needed.
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1074
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland


Return to Developers

Who is online

Users browsing this forum: No registered users and 3 guests