Settings and what to do afterwards

While starting my channel the first time, only a message will be displayed that no configuration exists... After entering all needed informations within the provided settings the channel should be refreshed and an initial layout should be displayed without restarting the whole plex server. Is it possible to realize this?

 

The example Pandora Channel shows the way but without a refresh...

def MainMenu():
oc = ObjectContainer(no_cache=True)
if not Prefs['pan_user'] or not Prefs['pan_pass']:
    oc.add(PrefsObject(title='Set your Pandora Preferences', thumb=R(ICON_PREFS)))
    return oc
else:
    oc.add(DirectoryObject(key=Callback(StationList), title='Your Stations'))
    oc.add(DirectoryObject(key=Callback(ManageStations), title='Manage Stations'))
    oc.add(PrefsObject(title='Change your Pandora Preferences', thumb=R(ICON_PREFS)))

return oc

The function ValidatePrefs() is used to validate the preferences. But how can I refresh the channel and "restart" the MainMenu()?

Greets

Sascha

Is there a reason why the method in Pandora won't work for you? 

If you notice, the no_cache=True in the definition of the ObjectContainer, that means that the contents are refreshed every time the user opens that screen... after navigating to/from preferences, in-to/out-of submenus. As long as you have a valid test for whether the necessary prefs are filled in AND make sure that you are not assigning prefs values to Global variables (they won't refresh), it should work.

Ok, I found that I had to use local variables within the MainMenu function. Now the refresh works...

The only trouble I still have, is the use of "ValidatePrefs". This function is called after "Saving" the preferences. How can I make the MainMenu refresh the ObjectContainer from within "ValidatePrefs" without using global variables?

Ok, I found that I had to use local variables within the MainMenu function. Now the refresh works...

The only trouble I still have, is the use of "ValidatePrefs". This function is called after "Saving" the preferences. How can I make the MainMenu refresh the ObjectContainer from within "ValidatePrefs" without using global variables?

You don't need ValidatePrefs(). Just include no_cache=True in the definition of the ObjectContainer. It will automatically refresh.

In regards to handling Prefs, in the context of Plex channels, the best practice is to just reference them directly whenever you need them via the Prefs['pref_name']. On occasion, I have also implemented a method to build a response using one or more pref values. The trick is that if you assign the pref value to a variable (whether local or [even worse] global), the value of the variable does not change when the value of the pref does. You need to re-assign the value of the variable. That's why it's better to call the Prefs[] directly.

Ok, I understand. I've added error handling to my TV-Headend Channel.

But I still have the problem, that the error messages will still be displayed even after entering the working preferences. I tried to overwrite header/message with none (as you can see). Seems that it's still be cached.

The network connection works but displaying the error message remains until server restart...

If you're testing with Plex/Web, it's likely a browser cache issue. Try clearing the browser cache and see what happens.

I think you're right. The problems do not exist within the ios app...

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.