0

Some popular, commercially available HTML5 video players are essentially big chunks of JavaScript. JWPlayer is one. I use a different one but it's similar in set up.

These players embed in a way that seems out of step with client-side MVC frameworks in general. The players want to render themselves to the DOM. You instantiate a player object and pass a DOM element to it's constructor. Like...

    mediaPlayer = new CommercialVideoPlayer("some-place-in-DOM");

The player then renders itself to "some-place-in-DOM".

Doesn't that conflict with view rendering in marionette - with the region manager showing views?

In other words this "player rendering itself" thing seems, on my first look, to conflict with the notion that marionette wants to render. It wants its region manager to map views to DOM elements. It doesn't want some player sticking things in the DOM.

It wants to do...

    someRegion.show(someView);

I'm not wrapping my brain around where my HTML5 video player goes in there? Inside a view?

When I put it inside a view and then attempt to show it, like...

    videoRegion.show(videoView);//media player is inside videoView

...I get nothing because marionette's region manager and the player are fighting over who gets to render where.

I think I just lack a conceptual understanding of what marionette js would want me to do with this media player. I'm looking for an understanding and a best practice.

4

1 回答 1

0

Marionette 区域经理想要显示 Marionette 视图。时期。他们不关心这些观点的作用。

换句话说,您可以让视图创建 DOM 元素,然后显示视频播放器,例如:

var VideoView = Marionette.ItemView.extend({
  template: _.template('<div id="video-player"></div>'),

  onShow: function(){
    this.mediaPlayer = new CommercialVideoPlayer("some-place-in-DOM");
  }
});

var myVideoView = new VideoView();

videoRegion.show(myVideoView);

以上是未经测试的伪代码,但应该让你朝着正确的方向前进。

于 2013-11-14T08:52:47.227 回答