Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with videos #416

Open
peteringram0 opened this issue Nov 29, 2016 · 2 comments
Open

Issue with videos #416

peteringram0 opened this issue Nov 29, 2016 · 2 comments

Comments

@peteringram0
Copy link

Hey,

Im adding a video to the DOM in the following way:

this.items = [h(`video#${item.id}`, {
                class: 'media-item',
                key: item.id,
                preload: 'auto'
            }, [
                h(`source`, {
                    src: item.src,
                    type: 'video/mp4'
                })
            ])];

var patches = diff(this.tree, h('div', this.items));
        this.rootNode = patch(this.rootNode, patches);
        this.tree = this.items;

I then want to start this video so i am doing a normal query selector then trying to run .play() on the element.

let el = document.getElementById(item.id)
el.play();

However the video does not play at all. Does anyone else have this issue with video?

Thanks,

@peteringram0
Copy link
Author

Anyone know about this at all ? Thanks

@chinedufn
Copy link

chinedufn commented Jan 23, 2017

Hey @peteringram0,

One way to approach this would be to use hooks. Here's a quick example:

var PlayHook = function (isPlaying) {
  this.isPlaying = isPlaying
}

PlayHook.prototype.hook = function (videoNode) {
  this.isPlaying ? videoNode.play() : videoNode.pause()
}

// ...

h('video', {
  src: src,
  playHook: new PlayHook(true),
})

// ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants