jplayer / jPlayer

jPlayer : HTML5 Audio & Video for jQuery
http://jplayer.org/
Other
4.6k stars 1.47k forks source link

Allow Jplayer have multiple dynamic instances #88

Closed azuby closed 11 years ago

azuby commented 12 years ago

JPlayer can currently only support multiple instances if a unique selector and corresponding UI selector can be supplied for each. When dynamically generating instances it's sometimes not possible (or not convenient) to generate a unique css selector for each instance and then dynamically fill in that selector in the js file and the html file.

This seems like an unnecessary restriction and I believe it is due to the fact that cssSelectorAncestor can only accept a string and not a selector object that can be found using jQuery's tree traversal. Due to the fact that cssSelectorAncestor is unaware of what instance is being referenced, it is not possible to have multiple JPlayer instances added dynamically to a page. I think this could be solved by instancing JPlayer to class or

happyworm commented 11 years ago

jPlayer allows you to instance onto a group of classes: $('.player').jPlayer(options)

I see the problem with the cssSelectorAncestor though... You could do what you asked using the ready event and then traverse the relative DOM and select the node to use. You'd need an ID on it though.

There is a PR with something similar to this on it. I had rejected it because I was not happy with something... Maybe backwards compatibility... I will revisit it.

happyworm commented 11 years ago

Yes, the PR was #94