VicMoore 560 Posted November 24, 2023 Share Posted November 24, 2023 I have a plugin where I am updating configuration data in my JS via the ApiClient ApiClient.getPluginConfiguration(pluginId).then((config) => { // the config object is updated here ApiClient.updatePluginConfiguration(pluginId, config).then((r) => { console.log("===== config updated = ", config); }); }); This code works perfectly. I now want to access this same data in my C# code but I don't know how to do it, or even if it's possible. Does anyone have a simple C# code example that I can use in my plugin to access the PluginConfiguration data above? Vic Link to comment Share on other sites More sharing options...
Luke 37094 Posted November 24, 2023 Share Posted November 24, 2023 Is this related to your virtual tv tuner? If yes then don't go down this avenue, just use the example I gave you. Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 24, 2023 Author Share Posted November 24, 2023 (edited) @LukeI tried using ApiClient.saveTunerHostConfiguration(info).then(function (result) { }, function (result) { }); where "info" is the stringified object that I want to send. This works but it also creates a new tuner. This also happens in virtualTVExample and tvheadin. I can't figure out how to stop creating the tuner. Should I start by deleting the current tuner? Vic Edited November 24, 2023 by VicMoore Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 24, 2023 Author Share Posted November 24, 2023 I have tried using ApiClient.saveTunerHostConfiguration(info).then(function (result) { }, function (result) { }); To send config info (in this example, "info") to a tuner. Examples are given in the virtualTvExample and TVHeadin plugins. In each case the "saveTunerHostConfiguration" works OK, but it creates a new tuner. Is this normal? Can I change this behavior? If not, should I remove the current tuner? Is there any documentation? VIc Link to comment Share on other sites More sharing options...
Luke 37094 Posted November 24, 2023 Share Posted November 24, 2023 HI, something about your code must be off and not following the example that I gave you. All of the tuner plugins are using that same code and they don't have any problem of repeat tuner hosts getting created. Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 24, 2023 Author Share Posted November 24, 2023 (edited) @LukeI agree, but it only works in the examples you pointed out because "saveTunerHostConfiguration" in the javascript is only called once. The problem is in the javascript code. I will keep studying. Do you have an example where the javascript is communicating multiple times to the C# code? I was considering using the pluginConfiguration as a simple means for communicating between the JS and C# code as a quick fix. I am a novice with plugins and in many ways C#. So, this is a big task for me. The good part is that I will learn a lot. Vic Edited November 24, 2023 by VicMoore Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 24, 2023 Author Share Posted November 24, 2023 @Lukewould it be possible for you to add to the virtualTVExample a javascript method (and associated C# code) that transfers an object to the C# code? It would be a great favor to me. I am doing well on the GUI. Vic Link to comment Share on other sites More sharing options...
Luke 37094 Posted November 24, 2023 Share Posted November 24, 2023 1 hour ago, VicMoore said: @LukeI agree, but it only works in the examples you pointed out because "saveTunerHostConfiguration" in the javascript is only called once. Just call it once like the example, then it redirects back to the main list of tuners. Stick to that pattern. https://github.com/MediaBrowser/VirtualTVExample/blob/master/VirtualTVExample/web/virtualtvexample.js#L74 I just updated the example with code from tvheadend. Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 25, 2023 Author Share Posted November 25, 2023 @Lukeyou are being a bit unfair. You are a giant with the Emby Architecture. I am just an ant. I am a skilled and experienced programmer, but I have no idea what it means to "then it redirects back to the main list of tuners" means because the architecture is not documented for people like me. I can't figure out how this redirect moves data from my JS code to the tuner C# code. I don't even know where to begin or how the architectural pieces connect and work together. The process must have a way for me to post the data (within my JS code) to the server where it will be picked up by the C# code in the tuner. Perhaps this happens by overriding a method. I don't know. This is why I was looking in the ApiClient for a solution. I know I have troubled you too much. You have many responsibilities. Do you know someone that might be able to help me. I sent Chef a note but he has not answered yet. Luke, don't get me wrong. I greatly appreciate your help. You have taught me a lot. You have planted a seed and it will grow. Vic Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 25, 2023 Author Share Posted November 25, 2023 Luke, I did the work. Using the code pattern you suggested It writes once to the tuner, and that works as expected. Next, as you explained, the code redirects back to the "Live TV" tab. This does work because it denies the possibility to write to the tuner a second time. I need to update the tuner to add channels and programs. Vic. 1 Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 25, 2023 Author Share Posted November 25, 2023 (edited) @LukeI started fresh with a new copy of virtualTVExample. And everything worked as expected. Once I save I end up in the "Live TV" tab. So I removed //appRouter.show(appRouter.getRouteUrl('LiveTVSetup', { // SavedTunerHostId: (result || {}).Id || info.Id, // IsNew: params.id == null //})); Now after the save, I return to my GUI. I don't know yet if this change destroys what you were trying to do. I will continue testing. Thanks so much for this help. Sometimes I am a bit slow to catch on. Vic Edited November 25, 2023 by VicMoore 1 Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 25, 2023 Author Share Posted November 25, 2023 further testing confirms that everything works ok. I can now transfer data to the tuner "YEA" Thanks so much... Vic Link to comment Share on other sites More sharing options...
Luke 37094 Posted November 26, 2023 Share Posted November 26, 2023 On 11/25/2023 at 10:45 AM, VicMoore said: @LukeI started fresh with a new copy of virtualTVExample. And everything worked as expected. Once I save I end up in the "Live TV" tab. So I removed //appRouter.show(appRouter.getRouteUrl('LiveTVSetup', { // SavedTunerHostId: (result || {}).Id || info.Id, // IsNew: params.id == null //})); Now after the save, I return to my GUI. I don't know yet if this change destroys what you were trying to do. I will continue testing. Thanks so much for this help. Sometimes I am a bit slow to catch on. Vic I wouldn't suggest this. Future updates to this screen might not make it possible to go off-script from the usual flow. Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 28, 2023 Author Share Posted November 28, 2023 @LukeIf I don't remove this code then every time I update the tuner I will end up on the Live Tv Tuner page, when I want to be displaying my GUI. Is there a work around? Could you explain why the code I deleted is necessary? I am making great progress on a new GUI. I have no problem now with transferring channel and program information to the tuner. I can build the EPG and everything plays properly. Vic Link to comment Share on other sites More sharing options...
VicMoore 560 Posted November 28, 2023 Author Share Posted November 28, 2023 @LukeI have experimented with the flow and I think I now understand. Rather than creating a menu selection in the sidebar, I just continue the setup of a tuner by clicking on the tuner to bring up my GUI to build the channels and programs for that specific tuner. Vic Link to comment Share on other sites More sharing options...
Luke 37094 Posted November 28, 2023 Share Posted November 28, 2023 5 hours ago, VicMoore said: @LukeIf I don't remove this code then every time I update the tuner I will end up on the Live Tv Tuner page, when I want to be displaying my GUI. Is there a work around? Could you explain why the code I deleted is necessary? I am making great progress on a new GUI. I have no problem now with transferring channel and program information to the tuner. I can build the EPG and everything plays properly. Vic No it won't be everytime, only when adding a new tuner. What is likely to happen in the future is this mechanism will change so that the tuner plugin only implements a portion of the page, not the entire thing, which means you won't have any control over the navigation workflow. That's why I would try to stay within those bounds now to avoid pain later. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now