Try this:Basically, you need to add the VideoElement to the document. And the "play" call is unnecessary with autoplay = true.#import ('dart:html');void main () {var videoClip = new VideoElement();videoClip.src="http://slides.html5rocks.com/src/chrome_japan.webm";videoClip.height=100;videoClip.width=100;videoClip.autoplay=true;document.body.nodes.add(videoClip);}
- John--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
I try with your code, but it doesn't work.
and my IDM also catched link download.
> And if you want to play it explicitly, do this:
>
> void main () {
> var videoClip = new VideoElement();
> videoClip.src = "http://slides.html5rocks.com/src/chrome_japan.webm";
> videoClip.height = 100;
> videoClip.width = 100;
> videoClip.on['canplay'].add((_) {
> videoClip.play();
> });
> document.body.nodes.add(videoClip);
> }
Couldn't you just do
videoClip.on['canplay'].add(videoClip.play);
?
Also, setting the videoclip's properties is a great opportunity to exercise cascades:
var videoClip = new VideoElement()
..src = "http://slides.html5rocks.com/src/chrome_japan.webm"
..height = 100
..width = 100
..on['canplay'].add(videoClip.play);
Not sure about the on['canplay'] thing here, I still struggle with more complex expressions in cascades. (Maybe the original proposal with curly braces wasn't that bad idea after all :-) )
LT
Not sure about the on['canplay'] thing here, I still struggle with more complex expressions in cascades. (Maybe the original proposal with curly braces wasn't that bad idea after all :-) )
--
var videoClip = new VideoElement()
..src = "http://slides.html5rocks.com/src/chrome_japan.webm"
..height = 100
..width = 100
..on['canplay'].add(videoClip.play);Not sure about the on['canplay'] thing here, I still struggle with more complex expressions in cascades. (Maybe the original proposal with curly braces wasn't that bad idea after all :-) )
SourceElement source = new SourceElement();
source.src = "myvideo.webm";
source.type = "video/webm";
video = new VideoElement();
video.nodes.add(source);
video.play();
var videoClip = new VideoElement().{
height = 100;width = 100;
on.{canPlay.add(videoClip.play);playing.add(...);}};
>> Initially, I wasn't sure about ".{" but I think I like it in these examples. Why was this discarded?
>
>
> I'm not really sure. I wasn't in the room when Lars, Gilad, and Kasper came up with the other syntax. If I remember right, they didn't like using curly braces in the context for some reason, but I don't know the details.
IIRC, it was because curly braces always introduce a new scope in Dart (or do they? I can't think of a situation when they don't). And this "visual rule" would be broken.
LT