Improve program.getSelection() API

Everything, that fits not well into other forums - Questions, Talk, Beta-Versions ...
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Improve program.getSelection() API

Postby SilverEagle » 18. Dec 08, 08:45

Hi Team,

Currently the program.getSelection() does two different things which sound similar but are definitely diffent, while the caller has no idea which function was performed. (One is returning the selection from the workspace, if there is no seelction it is returning the queue.)

Could you fix this somehow so it will become a clean API with two separate calls for the two functions? From both a designers & programmers viewpoint I'd even like to change the existing functionality cause I cannot image any existing script using this reliably, even with a lot of workaround thinking I did not get my single-touch detector in BlueTouch/RedTouch working for 100% of possible situations.

Regards,
SilverEagle

User avatar
Service-Team
Posts: 2448
Joined: 7. Dec 04, 04:48
Location: Germany
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Improve program.getSelection() API

Postby Service-Team » 18. Dec 08, 09:48

Hello SilverEagle,

Thank you very much for your report.

We have checked the issue:

In the next version of Silverjuke (2.73 or later), program.getSelection() will have an additional parameter to define which URLs to return.

See http://www.silverjuke.net/sdk/program-g ... ction.html for details.

Best regards
Your Silverjuke-Team

SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Improve program.getSelection() API

Postby SilverEagle » 18. Dec 08, 10:37

Service-Team wrote:
> http://www.silverjuke.net/sdk/program-g ... ction.html

Unless I fully misunderstand the queue is identical to the 'display', and the queue is a property of the player, not the program. To me it sounds like getSelection(1) will return a program property, but getSelection(2) will return a player property.

I just tested something: there is also a third function!!! If there is also no selection in the playlist/queue, the complete playlist/queue is returned...

I was wondering why you did not want to create something like:

program.getSelection() -> returns selected lines from workspace

player.getSelection() (or getQueueSelection()) -> return selection from queue

And if you want to know the contents of the queue, a programmer can just use player.queueLength and getUrlAtPos().

I know all about compelling reasons for keeping an API unchanged, but I think the current behaviour could easily be called a bug and should preferably not be kept like it is...

Regards,
SilverEagle

User avatar
Service-Team
Posts: 2448
Joined: 7. Dec 04, 04:48
Location: Germany
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Improve program.getSelection() API

Postby Service-Team » 18. Dec 08, 11:05

Hello SilverEagle,

in the post above, when talking about the "display", this is equal to the "queue". If we would add a player.getSelection() function, this would be equal to program.getSelection(2).

The idea behind the current behaviour (return workspace/queue selection or all queued urls) is to simplyfy some functions. Eg. the internal "burn" dialog uses this approach, to get the seletion without worrying about where it comes from.

However, we understand that there are situations where these "smart selection returning" is not desired.

Maybe this clearifies some things.

Best regards,
Your Silverjuke-Team

SilverEagle
Posts: 713
Joined: 30. Sep 08, 14:00
Location: Netherlands
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Improve program.getSelection() API

Postby SilverEagle » 18. Dec 08, 11:23

> Eg. the internal "burn" dialog uses this approach

Ah, finally understood ;-) I which case it makes sense to keep this as wanted behaviour in case an existing script did something similar.

Personally I'd say keep the queue-related stuff all with the player object and not put this single function with the program object, but functionwise everything will be cleanly available so it really isn't that important.

Only maybe improve the new manual text "Returns the selection or the workspace or the display. If nothing is selected there, return all tracks in the display." to something like "Returns the selection in the workspace. If nothing is selected there, return the selection in the display. If nothing is selected there return all tracks in the display." The current description is a bit ambiguous I think.

And maybe add a reference to this fucntionality to for instance the Player.getUrlAtPos() entry? I think that is where you would look for it as a programmer (as I said: it's player related functionality ;-)).

Cheers,
SilverEagle

User avatar
Service-Team
Posts: 2448
Joined: 7. Dec 04, 04:48
Location: Germany
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Improve program.getSelection() API

Postby Service-Team » 18. Dec 08, 11:51

Thank you for your help, we've updated . Hopefully, some things are a little bit clearer now ;-)

Best regards,
Your Silverjuke-Team


[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Return to “Main Forum”