#414 ✓ staged
David Humphrey

Add ability to toggle commands on/off per instance

Reported by David Humphrey | March 16th, 2011 @ 11:37 AM | in 0.6

09:56 <@humph> I want to add a way to override all tracks of the same kind (that is globally enable/disable) and am pondering the right interface
09:56 <@humph> in essence
09:56 <@humph> I want something like Popcorn.disable('subtitles');
09:57 < rwaldron> scott ^
09:57 < rwaldron> thats doable
09:57 < rwaldron> it would be more like...
09:57 < scott> Popcorn.toggle('subtitles')?
09:57 < rwaldron> Popcorn("#video").disable("foo")
09:57 < rwaldron> ooooo, yeah... toggle
09:57 <@humph> toggle is good
09:57 < rwaldron> nice one
09:58 <@humph> then you can setup all your tracks, but something in the UI can turn them all off in one swoop
09:58 < rwaldron> i'd like to keep it "per instance"
09:58 < rwaldron> humph +1
09:58 <@humph> per instance meaning per popcorn/video instance?
09:58 < scott> if it is toggle, it has to be per instance
09:58 < rwaldron> yessir
09:58 <@humph> yeah, per popcorn instance
09:58 <@humph> agreed
09:58 < rwaldron> scott... idea
09:58 <@humph> dmose filed a ticket for something like this, but I think we want it for all track types
09:58 < rwaldron> this might not be best way, but I'm putting out
09:58 < rwaldron> we add 2 new static methods...
09:59 < rwaldron> Popcorn.enable( instance, command ), Popcorn.disable( instance, command )
09:59 < rwaldron> then...
09:59 < rwaldron> Popcorn("#video").toggle( "command" ) is just sugar
09:59 < brett> i <@humph> yeah
10:00 <@humph> rwaldron: do we have a way to query for all commands on the instance?
10:00 <@humph> what if I want to talk the list and toggle all?
10:00 <@humph> s/talk/walk/
10:00 < rwaldron> that way we have enable/diable if you want to hook into them
10:00 < scott> rwaldron: yeah, that's good
10:00 < rwaldron> humph, can you clarify two things...
10:01 < rwaldron> "the list"? the currently active commands?
10:01 <@humph> here's my use case
10:01 <@humph> 1) you want just the subtitles off (we covered that above)
10:01 <@humph> 2) you want to toggle *all* of it for the given instance
10:01 <@humph> go into "silent" UI mode
10:01 <@humph> and be able to bring it all back
10:02 <@humph> so, you need the commands that exist on this instanct
10:02 <@humph> e.g., map, subtitle, twitter, ...
10:02 <@humph> so you can toggle
10:02 < rwaldron> ok 
10:02 < rwaldron> to you want to be able to actually check what is there
10:02 <@humph> do we expose the list?
10:02 <@humph> Popcorn(...).commands ?
10:03 < rwaldron> not really, but thats trivial
10:03 <@humph> it doesn't have to be done that way in terms of API, but we need to be able to enumerate that list
10:03  * humph files the bug
10:03 < rwaldron> I'd prefer a "control" via the api
10:03 < rwaldron> that way we document the behaviour
10:04 <@humph> what do you mean by a control?
10:04 < rwaldron> hahaha... i'm not sure 
10:04 < rwaldron> a getter method?
10:04 <@humph> yeah
10:04 <@humph> details are TODO
10:04 < rwaldron> like you said above...
10:04 < rwaldron> Popcorn(...).commands
10:04 < rwaldron> or something
10:05 < brett> guys would something like this just hide things in CSS?
10:05 < brett> i've often presented a use case to people
10:05 < brett> that you could have popcorn happening in the background, but it might only be presented if the user chooses it to be
10:05 < rwaldron> no, it would be preventing the command from executing
10:06 < scott> rwaldron: all an executing command does is change the css (mostly)
10:06 < rwaldron> what you're talking about is more UI related and best handled independantly of Popcorn
10:06 < rwaldron> scott, thats only true now
10:06 <@humph> right
10:06 <@humph> we have nno idea what a command does
10:06 <@humph> it could do anything
10:06 < rwaldron> and we have to act like we will never know
10:06 <@humph> yup
10:07 <@humph> this lets all your tracks stay in queue, but not fire
10:07 < scott> so this is going to require a change to the update function
10:07 < brett> rwaldron right, i get it
10:07 < rwaldron> scott, minimal
10:07 < rwaldron> but yes
10:07 <@humph> yeah, it's 2 if checks
10:07 < rwaldron> and worth it
10:07 < scott> and maybe a disable/enable flag on a track?
10:07 <@humph> not o the track
10:08 <@humph> the track should talk to its command for a global on/off flag
10:08 <@humph> you don't want this on every instance
10:08 < rwaldron> i would just keep an array of what is "off" and assume everything else is "on"
10:08 <@humph> yeah
10:08 < scott> a plugin is alive on all instances, a track lives on one instance
10:09 < rwaldron> and that array will be a property of {popcorn}.data
10:09 < rwaldron> so, like...
10:09 < rwaldron> {popcorn}.data.disabled = [ "subtitle" ]
10:09 < rwaldron> means: subtitles are disabled
10:09 < scott> that might work
10:09 < rwaldron> easy
10:10 < rwaldron> i'd say a call to...
10:10 < rwaldron> Popcorn.disable( command ) // notice, no "instance" arg
10:10 < rwaldron> will use the Popcorn.instances to iterate and disable that command on ALL instances

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Popcorn.js is an HTML5 video framework that lets you bring elements of the web into your videos.

Popcorn.js is a project of Web Made Movies, Mozilla's Open Video Lab.

Shared Ticket Bins

Referenced by