2014-03-26 26 views
0

我有兩種,一種是視頻種類,另一種是包含視頻種類的自定義種類。我想將參數videoStream傳遞到類VideoPlayerPage中,並讓子類Video將此參數設置爲其src。我該怎麼做呢 ?在enyo.kind中引用參數()

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); 
    } 
}); 

回答

0

沒關係我想通了。我給我的Video類型命名爲「player」,然後將其設置在create函數中。

create : function(arg){ 
     this.inherited(arguments); 
     this.$.player.setSrc(this.stream); 
} 
+1

我會保留streamChanged函數並完成對setSrc的調用,如果流屬性發生更改,它也會更新。 – Pre101

+0

@Pre101那個更好的方法呢? – Fabii

+1

是的,我認爲通過「更改」功能讓您設置的屬性與其內部表示相關聯始終是個好主意。 – Pre101