How to use ccui.VideoPlayer in a layer?

Hi all, I wanted to insert a video player in a layer and with the added Video player in 3.7 I wanted to used, I tried this:

var videoLayer = cc.Layer.extend({

    ctor:function(){
        this._super();
        this.init();
    },

    init:function(){

        this._super();

        var video = new ccui.VideoPlayer("res/video/trailer.mp4");
        video.setContentSize(480, 270);
        video.setPosition(cc.winSize.width/2, cc.winSize.height/2);
        video.setScale(1);
        window.video = video;
        this.addChild(video);
    }
});

But only a black rectangle is shown, I tried converting the mp4 to ogg and webm (with miro video converter) but I have the same issue.
Can anybody help?

Hello,

I have used below code to play video. Which works fine for me.

var video = new ccui.VideoPlayer();
video.setContentSize(1212, 768);
video.setPosition(1212/2,768/2);
window.video = video;
this.addChild(video);
video.setURL(“res/video.mp4”);
video.play();

For me some of the mp4 video was not playing, I have converted video to html5-mp4 format using total video converter software.

Regards
Deepthi

Thanks a lot deepthi, you are of a tremendous help, that worked well :smile:
I was unaware that I needed to set it on play. :stuck_out_tongue:
Thanks again.