Merge branch 'v1.2' of github.com:cocos-creator/engine into v1.2

This commit is contained in:
Nan Wang
2016-08-16 17:16:23 +08:00
5 changed files with 65 additions and 11 deletions
+2 -1
View File
@@ -213,10 +213,11 @@ function refreshScene () {
else {
var i, node, nodes = widgetManager._nodesWithWidget, len = nodes.length;
if (CC_EDITOR && window._Scene && _Scene.AnimUtils && _Scene.AnimUtils.curAnimState) {
var editingNode = _Scene.AnimUtils.curRootNode;
for (i = len - 1; i >= 0; i--) {
node = nodes[i];
var widget = node._widget;
if (widget.isAlignOnce && animationState.animatedSinceLastFrame) {
if (widget.isAlignOnce && animationState.animatedSinceLastFrame && node.isChildOf(editingNode)) {
// widget contains in _nodesWithWidget should aligned at least once
widget.enabled = false;
}
+31 -7
View File
@@ -147,21 +147,24 @@ var VideoPlayer = cc.Class({
url: cc.RawAsset
},
_time: 0,
/**
* !#en The current time when video start to play.
* !#zh 从当前时间点开始播放视频
* !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
* !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。
* @property {Number} currentTime
*/
currentTime: {
tooltip: 'i18n:COMPONENT.videoplayer.currentTime',
type: cc.Float,
set: function ( time ) {
this._time = time;
this._sgNode.seekTo(time);
if(this._sgNode) {
this._sgNode.seekTo(time);
}
},
get: function () {
return this._time;
if(this._sgNode) {
return this._sgNode.currentTime();
}
return -1;
}
},
@@ -210,7 +213,6 @@ var VideoPlayer = cc.Class({
},
onLoad: function() {
if(CC_JSB) {
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
this.enabled = false;
@@ -318,6 +320,28 @@ var VideoPlayer = cc.Class({
}
},
/**
* !#en Gets the duration of the video
* !#zh 获取视频文件的播放总时长
*/
getDuration: function() {
if(this._sgNode) {
return this._sgNode.duration();
}
return -1;
},
/**
* !#en Determine whether video is playing or not.
* !#zh 判断当前视频是否处于播放状态
*/
isPlaying: function() {
if(this._sgNode) {
return this._sgNode.isPlaying();
}
return false;
}
});
cc.VideoPlayer = module.exports = VideoPlayer;
@@ -117,10 +117,11 @@
maxWidth -= 2 * this._getMargin();
var wrappedWords = [];
//fast return if strArr is empty
if(strArr.length === 0) {
if(strArr.length === 0 || maxWidth < 0) {
wrappedWords.push('');
return wrappedWords;
}
var text = strArr;
var allWidth = ctx.measureText(text).width;
while (allWidth > maxWidth && text.length > 1) {
@@ -222,6 +223,11 @@
var canvasWidthNoMargin = this._canvasSize.width - 2 * this._getMargin();
var canvasHeightNoMargin = this._canvasSize.height - 2 * this._getMargin();
if(canvasWidthNoMargin < 0 || canvasHeightNoMargin < 0) {
fontDesc = '1px ' + fontFamily;
this._labelContext.font = fontDesc;
return fontDesc;
}
totalHeight = canvasHeightNoMargin + 1;
maxLength = canvasWidthNoMargin + 1;
var actualFontSize = this._drawFontsize + 1;
@@ -251,7 +257,6 @@
textFragment = this._fragmentText(paragraphedStrings[i],
canvasWidthNoMargin,
this._labelContext);
var isBiggerSize = false;
while(j < textFragment.length) {
var measureWidth = this._labelContext.measureText(textFragment[j]).width;
maxLength = measureWidth;
@@ -73,6 +73,14 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{
return this._renderCmd.isPlaying();
},
duration: function () {
return this._renderCmd.duration();
},
currentTime: function() {
return this._renderCmd.currentTime();
},
createDomElementIfNeeded: function () {
if (!this._renderCmd._video) {
this._renderCmd.createDom();
@@ -501,6 +509,7 @@ _ccsg.VideoPlayer.EventType = {
};
proto.isPlaying = function () {
var video = this._video;
if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation && this._playing){
setTimeout(function(){
video.play();
@@ -509,4 +518,18 @@ _ccsg.VideoPlayer.EventType = {
return this._playing;
};
proto.duration = function () {
var video = this._video;
if(!video) return -1;
return video.duration;
};
proto.currentTime = function () {
var video = this._video;
if(!video) return -1;
return video.currentTime;
};
})(_ccsg.VideoPlayer._polyfill);
+2 -1
View File
@@ -359,7 +359,8 @@ var actionUpdate = {
'FadeOut': syncOpacityUpdate,
'FadeTo': syncOpacityUpdate,
'TintTo': syncColorUpdate,
'TintBy': syncColorUpdate
'TintBy': syncColorUpdate,
'BezierBy': syncPositionUpdate
};
for (var key in actionUpdate) {