mediacenterjs
mediacenterjs copied to clipboard
Make remote context aware
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.
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
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?
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.
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)
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.
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?
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!
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.