mediacenterjs icon indicating copy to clipboard operation
mediacenterjs copied to clipboard

Make remote context aware

Open jansmolders86 opened this issue 9 years ago • 8 comments

To support specific app features and the suggested in app plugins, the remote should be context aware and thus be able to add or remove buttons and functionality.

jansmolders86 avatar Jan 08 '15 17:01 jansmolders86

I was thinking of adding some kind of actions to mcjs-library-item, currently it would just be "watch" and "edit", and this could be applied to right click menus, pressing enter (a default action could be specified) and also to the remote

Jon889 avatar Jan 09 '15 01:01 Jon889

that would be a cool way of doing it as well! adding the context in the app itself. But still, How would you access "off canvas" items, like for instance the view switcher between track view and album view, That's pretty hard to get right with the current setup. I would be a lot easier when - if you open the music app - you get a specific button for that purpose on your remote. Would you agree?

jansmolders86 avatar Jan 09 '15 08:01 jansmolders86

Ah yes I hadn't considered off canvas actions. Perhaps create a remote service/factory to have an array of actions that can be sent from the remote and have directives add items to this list, and when they are then it sends messages to the remote page using websockets to show or hide the relevant actions?

Then for off canvas actions there'd be a directive used like: `remote-action="Show hidden" which will add an action to the remote service such that when the respective button on the remote is pressed the directive will call the ng-click handler.

Jon889 avatar Jan 12 '15 15:01 Jon889

Very cool Jonathan, So let me get this straight, would the plugin itself control the aditional remote options by adding directives? Or how would that be handled? (trying to paint a picture in my head)

jansmolders86 avatar Jan 12 '15 17:01 jansmolders86

So like line 31 in movies would be:

label.view-select(mcjs-remote-action="query.hidden ? 'Show Hidden' : 'Hide Hidden'" for="showhidden", ng-init="query.hidden='false'", ng-click="query.hidden = query.hidden == 'false' ? '' : 'false'")

So when the value of mcjs-remote-action is updated it will send a message over web sockets to the remote containing the name, and a button would be added to the remote with the name (or I guess you could supply a URL for an image)? I think this would work, I've not tried any of it.

Jon889 avatar Jan 12 '15 17:01 Jon889

I've created a new branch with an implementation of contextual actions. Working for the Show/Hide Hidden button in the Movies app. Is this what you were thinking?

Jon889 avatar Jan 13 '15 11:01 Jon889

It looks like a pretty nifty piece of code Jonathan! I'm learning a great deal from you. It's very interesting to see you choose to implement stuff using directives rather than messing about in the dom itself. (what I tend to do to often) Very cool! I'll check out the functionality asap!

jansmolders86 avatar Jan 14 '15 18:01 jansmolders86

I'm learning as I go along so I hope I'm doing it the right way :) I had trouble with the way I wanted to implement actions on items in the library because it seems impossible to access an elements attributes within in an attributes value, so I think it will have to be done directly in the directives code, which seems slightly less tidy.

Jon889 avatar Jan 21 '15 10:01 Jon889