Referencing a parameter in enyo.kind()

edited March 2014 in Newbie Questions
I have two kinds, one is video kind and the other is a custom kind which contains a video kind. I want to pass a parameter videoStream into the kind VideoPlayerPage and have the subkind Video set this parameter as its src. How do I do this ?
 var el  =  new VideoplayerPage({stream: videoStream });
    el.renderInto(document.getElementById("formContainer")); 

 
    enyo.kind({
            name: "Videoplayer",
            kind : "Video",
            style: "margin-top: 100px;",
            poster : null,
            src : null
        });
    
    
    enyo.kind({
        name: "VideoplayerPage",
        kind: "FittableRows",
        style: "margin-top: 100px;",
        published: {
            stream : null
        },
        create : function(){
            this.inherited(arguments); 
            this.streamChanged();
            console.log("Creating video page"+ this.stream);
        },
        classes: "data-grid-list-sample data-repeater-sample enyo-fit", 
        components : [
            {kind : "Videoplayer", src: this.stream, showControls : true, fitToWindow : true, autoplay :true},
            {tag: "br"},
            {kind : "moon.Button"},
            {kind : "moon.Button"}
        ],
        streamChanged: function() {
            //this.$.stream.setContent(this.stream);
            this.setStream(this.stream);
        }
    });

Comments

  • There are two ways to do this: observers and bindings. With observers (like you have above), you have to manually notify observers in create(). With bindings, the framework will automatically connect the bindings.

    Both in action: http://jsfiddle.net/ryanjduffy/S5H5D/1/
  • I gave my Video kind a name "player" then in set it in the create function .

    I will use your suggestion as well, thanks.
        create : function(arg){
                this.inherited(arguments); 
                this.$.player.setSrc(this.stream);
        }
Sign In or Register to comment.