- 浏览: 335234 次
- 性别:
- 来自: 广州
-
文章分类
- 全部博客 (299)
- 私人 (3)
- linux (22)
- web service (1)
- java applet (1)
- java (41)
- c# (1)
- socket (1)
- android (10)
- htc (1)
- root (1)
- ftp (3)
- 系统备份 (0)
- jquery (3)
- 图表 (1)
- 实用 (4)
- web (9)
- css (3)
- java applet mplayer (1)
- mplayer (4)
- javascript (8)
- eclipse (1)
- 正则表达式 (1)
- jmf (1)
- tomcat (6)
- 驱动 (1)
- 嵌入式 (1)
- usb (3)
- ffmpeg (1)
- player (1)
- encode (1)
- ajax (1)
- 单纯形复法 (1)
- rom (1)
- ndk (1)
- 打印 (1)
- vs2010 (2)
- myeclipse注册机 (1)
- c++ (5)
- capture (0)
- 串口 (1)
- windows (2)
- mingw (1)
- 网卡 (1)
- 绿色版 (1)
- cywin (1)
- x264 (1)
- 恢复文件 (1)
- servlet init 连数据库 (1)
- 51 单片机 (1)
- 操作系统 (1)
- vlc (3)
- 网线 (1)
- CListBox (1)
- mfc (1)
- setTimer (1)
- 分屏 (1)
- 供求信息 (1)
- 导航 (1)
- 批处理 (1)
- dos (1)
- mysql (5)
- MySQL新建用户 (1)
- demo (1)
- vc (1)
- webservice (1)
- 书签 (1)
- 浏览器 (1)
- spring mvc (1)
- excel (1)
- VPN (0)
- sql (1)
- pdf (3)
- arp (1)
- jsp (2)
- IE (1)
- html (1)
- test (3)
- httpclient (1)
- spring mvc 上传 (1)
- easyui (1)
- mybatis (1)
- spring (1)
- 微信 (1)
- weixin (2)
- pay (2)
- maven (2)
- fastdfs (2)
- ELK (2)
- logstash (1)
- rocketMQ (0)
- jmeter (0)
- 测试 (0)
- softether (0)
- util (0)
最新评论
-
ice24:
ftp client applet -
wuzijingaip:
499700647 写道你好,看了您的文章《ftp clien ...
ftp client applet -
zxcv193188:
感谢楼主
java JMF的使用 -
499700647:
你好,看了您的文章《ftp client aplet》很受启发 ...
ftp client applet -
JoeBaby_:
非常感谢,看文档的时候觉得JMF好难的样子,但是看过代码后思路 ...
java JMF的使用
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TextCanvas Demo</title>
<script>
var video = document.querySelector('video');
var togglePlay = document.querySelector('#play');
var position = document.querySelector('#position');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');
addEvent(togglePlay, 'click', function () {
video.playbackRate = 0.5;
if (video.paused) {
if (video.ended) video.currentTime = 0;
video.play();
this.value = "pause";
} else {
video.pause();
this.value = "play";
}
});
addEvent(video, 'timeupdate', function () {
position.innerHTML = asTime(this.currentTime);
// ctx.restore();
ctx.drawImage(video, 0, 0, video.width, video.height, 0, 0, canvas.width, canvas.height);
});
addEvent(video, 'ended', function () {
togglePlay.value = "play";
});
addEvent(video, 'canplay', function () {
video.muted = true;
document.querySelector('#duration').innerHTML = asTime(this.duration);
startCanvas();
});
function startCanvas() {
canvas.setAttribute('height', Math.floor(video.height));
canvas.setAttribute('width', Math.floor(video.width));
ctx.translate(canvas.width/2, canvas.height/2);
ctx.scale(-1, 1);
ctx.translate(-canvas.width/2, -canvas.height/2);
ctx.drawImage(video, 0, 0, video.width, video.height, 0, 0, canvas.width, canvas.height);
// var mirror = canvas.height * 0.6;
// var grad = ctx.createLinearGradient(0, 0, 0, mirror);
// grad.addColorStop(0, 'rgba(0, 0, 0, 0.5)');
// grad.addColorStop(1, 'rgba(0, 0, 0, 1)');
// ctx.fillStyle = grad;
// ctx.rect(0, 0, canvas.width, mirror);
// ctx.fill();
// ctx.save();
}
function asTime(t) {
t = Math.round(t);
var s = t % 60;
var m = Math.round(t / 60);
return two(m) + ':' + two(s);
}
function two(s) {
s += "";
if (s.length < 2) s = "0" + s;
return s;
}
</script>
<script type="text/javascript">
function TextCanvas(container) {
this.container = container;
if (!container.style.position)
container.style.position = 'relative';
var canvas = document.createElement('canvas');
this.canvas = canvas;
canvas.style.position = 'absolute';
container.appendChild(canvas);
this.labels = [];
}
// Font and text properties. These are applied to strings that are
// rendered with drawString.
TextCanvas.CSSStringProperties = 'color direction fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineHeight textAlign textDecoration textIndent textShadow textTransform unicodeBidi whiteSpace wordSpacing'.split(' ');
TextCanvas.prototype.getContext = function(contextID) {
var ctx = this.canvas.getContext(contextID);
if (contextID == '2d')
this.attachMethods(ctx, this);
return ctx;
};
TextCanvas.prototype.setDimensions = function(width, height) {
var container = this.container;
var canvas = this.canvas;
// "canvas.width = width" doesn't work in Safari
canvas.setAttribute('width', width);
canvas.setAttribute('height', height);
this.container.style.width = width;
this.container.style.height = height;
}
TextCanvas.prototype.clear = function() {
var canvas = this.canvas;
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (var i = 0; i < this.labels.length; i++)
this.container.removeChild(this.labels[i]);
this.labels = [];
};
TextCanvas.prototype.attachMethods = function(ctx, controller) {
ctx.drawString = function(x, y, string) {
controller.addLabel(x, y, string);
};
ctx.clear = function () {
controller.clear();
};
ctx.stringStyle = controller.container.style;
};
TextCanvas.prototype.addLabel = function(x, y, string) {
var label = document.createElement('div');
label.innerHTML = string;
var style = this.container.style;
var cssNames = TextCanvas.CSSStringProperties;
for (var i = 0; i < cssNames.length; i++) {
var name = cssNames[i];
label.style[name] = style[name];
}
label.style.position = 'absolute';
label.style.left = x;
label.style.top = y;
this.container.appendChild(label);
this.labels.push(label);
}
</script>
</head>
<body>
<video height="360" width="480">
<source src="file:::///C:/media/video/WMV_720P_Amazon.wmv" />
<source src="dizzy.ogv" />
</video>
<p>
<input type="button" id="play" value="play">
<span id="position">00:00</span> / <span id="duration"></span>
</p>
<canvas id="cc"></canvas>
<table>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
</table>
<div id="canvas-container" width=100 height=100>
</div>
<table>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
<tr>
<td>
rfgtyhuyughghb
</td>
</tr>
</table>
<video autoplay="true" controls="true" src="http://videos.mozilla.org/firefox/3.5/meet/meet.ogv" width="640" height="360">您的浏览器不支持 video 标签。</video>
<script type="text/javascript">
var textshow = 'umNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNumNum';
var controller = new TextCanvas(document.getElementById('canvas-container'));
controller.setDimensions(400, 300);
var ctx = controller.getContext('2d');
var midx = 300/2, midy = 100/2;
var tttt = 0,aaa=0;
function redraw(ctx, t) {
/*for (i=0;i<4;i++){
for(j=0;j<3;j++){
ctx.beginPath();
var x = 25+j*50; // x coordinate
var y = 25+i*50; // y coordinate
var radius = 20; // Arc radius
var startAngle = 0; // Starting point on circle
var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle
var anticlockwise = i%2==0 ? false : true; // clockwise or anticlockwise
ctx.arc(x,y,radius,startAngle,endAngle, anticlockwise);
if (i>1){
ctx.fill();
} else {
ctx.stroke();
}
}
}
quadraticCurveTo(cp1x, cp1y, x, y) // BROKEN in Firefox 1.5 (see work around below)
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)
// Quadratric curves example
ctx.beginPath();
ctx.moveTo(75,25);
ctx.quadraticCurveTo(25,25,25,62.5);
ctx.quadraticCurveTo(25,100,50,100);
ctx.quadraticCurveTo(50,120,30,125);
ctx.quadraticCurveTo(60,120,65,100);
ctx.quadraticCurveTo(125,100,125,62.5);
ctx.quadraticCurveTo(125,25,75,25);
ctx.stroke();
*/
// Bezier curves example
ctx.beginPath();
ctx.moveTo(75,40);
ctx.bezierCurveTo(75,37,70,25,50,25);
ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
ctx.bezierCurveTo(20,80,40,102,75,120);
ctx.bezierCurveTo(110,102,130,80,130,62.5);
ctx.bezierCurveTo(130,62.5,130,25,100,25);
ctx.bezierCurveTo(85,25,75,37,75,40);
ctx.fill();
tttt++;
aaa++;
tttt = ( (tttt % (textshow.length * 10 )));
var u = 2*t;
var v = 3*t;
var p0 = {x: midx + midx*Math.cos(u), y: midy + midy*Math.sin(u)};
var p1 = {x: midx + midx*Math.cos(v), y: midy + midy*Math.sin(v)};
ctx.clear();
ctx.moveTo(p0.x, p0.y);
ctx.lineTo(p1.x, p1.y);
/* ctx.moveTo(p0.x, p0.y);
ctx.lineTo(p0.x + 8, p1.y % p0.y +

ctx.moveTo(p0.x, p0.y);
ctx.lineTo(p1.x % p0.x - 8, p1.y % p0.y +

ctx.stroke();
ctx.stringStyle.color = 'red';
ctx.stringStyle.fontSize = 12;
ctx.drawString(p0.x, p0.y, 'A');
ctx.stringStyle.color = 'blue';
ctx.stringStyle.fontSize = 18;
ctx.drawString(p1.x, p1.y, 'B');
ctx.stringStyle.color = 'green';
ctx.stringStyle.fontSize = 60;
ctx.drawString(800 - tttt ,100, u+'a'+textshow.length+'--'+textshow +tttt);
ctx.stringStyle.color = '#a33aac';
ctx.stringStyle.fontSize = 50;
ctx.drawString(p1.x +aaa % 800, p1.y+aaa % 800-300,'abcdefg');
ctx.stringStyle.color = '#aacabc';
ctx.stringStyle.fontSize = 50;
ctx.drawString(800-(p1.x +aaa % 800), p1.y+aaa % 800-300,'2134654');
}
// don't mistake me for a real animation system!
var animation = {timer: null, value: 0, duration: 5 * 1000};
function stepAnimation() {
var t = (new Date().getTime() - animation.startTime) / animation.duration;
animation.value = t %= 1.0;
redraw(ctx, t * 2* Math.PI);
}
function startAnimation() {
var framerate = 30;
animation.startTime = new Date().getTime() - animation.value * animation.duration;
animation.timer = animation.timer || setInterval(stepAnimation, 1000/framerate);
}
startAnimation();
</script>
</body>
</html>

相关推荐
WPF提供了多种布局容器,如Canvas、WrapPanel、UniformGrid等,它们根据特定规则排列子元素。例如,WrapPanel会在一行内排列元素,当空间不足时换行。 **9. 控件模板与数据模板** 控制模板允许自定义控件的视觉外观...
L的列子代码 目录: googledemo.customview 谷歌的demo projectl AppForegroundStateManager 检测Android应用的启动与关闭 CustomView 自定义View CustomTitleView 自定义标题的view CustomImageView 自定义...
提供的"WebCast20101102_Demo"文件应该包含示例代码和演示,建议配合学习,以便更好地理解和掌握Silverlight布局的使用。 总之,Silverlight的布局系统为开发者提供了丰富的选择和强大的灵活性,是创建美观且响应式...
`ViewDemo`中可能包含一个自定义网格布局的示例,使得可以更灵活地排列子View。 4. 功能型自定义View:这类自定义View通常是为了实现特定的功能,比如计数器、日历等。它们可能需要额外的数据模型和业务逻辑。在`...
教程可能讲解如何使用Unity的UI组件(如Canvas、Text、Button等)来构建游戏菜单、提示信息、计分板等,并通过C#脚本来响应用户的输入事件。 七、物理系统与碰撞检测 Unity3D内置了强大的物理引擎,支持刚体动力学...