Skip to content

Commit

Permalink
Cleanup older code, write in accordance with present Annotation frame…
Browse files Browse the repository at this point in the history
…work
  • Loading branch information
Harshavardhana committed Nov 2, 2014
1 parent fd0f2f7 commit 19ce390
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 50 deletions.
52 changes: 3 additions & 49 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {

var VideoAnnotation = (function VideoAnnotationClosure() {
function VideoAnnotation(params) {
Annotation.call(this, params);
InteractiveAnnotation.call(this, params);
if (params.data) {
return;
}
Expand All @@ -562,6 +562,7 @@ var VideoAnnotation = (function VideoAnnotationClosure() {

var dict = params.dict;
var data = this.data;
data.annotationType = AnnotationType.VIDEO;
// Check for various annotations related to videos.
if (dict.get('Subtype').name === 'Screen') {
data.contentType = dict.get('A').get('R').get('C').get('CT') || '';
Expand Down Expand Up @@ -590,55 +591,8 @@ var VideoAnnotation = (function VideoAnnotationClosure() {
data.src = dict.get('Movie').get('F').get('F');
}
}
Util.inherit(VideoAnnotation, Annotation, {
hasHtml: function VideoAnnotation_hasHtml() {
return true;
},

getHtmlElement: function VideoAnnotation_getHtmlElement(commonObjs) {
var contentType = this.data.contentType;
var element = document.createElement('video');
var checkSupport = element.canPlayType(contentType);
if (checkSupport === 'probably') {
element.src = this.data.src || '';
element.type = contentType || '';
element.poster = this.data.poster || '';
element.controls = true;
} else if (contentType in navigator.mimeTypes) {
element = document.createElement('object');
element.data = this.data.src || '';
element.type = this.data.contentType || '';
var param = document.createElement('param');
param.name = 'controller';
param.value = true;
element.appendChild(param);
var param2 = document.createElement('param');
param2.name = 'uiMode';
param2.value = 'mini';
element.appendChild(param2);
} else {
warn('Cant play the video, unsupported');
}

var rect = this.data.rect;
var borderWidth = this.data.borderWidth;
Util.inherit(VideoAnnotation, InteractiveAnnotation, { });

element.style.borderWidth = borderWidth + 'px';
var color = this.data.color;
var rgb = [];
for (var i = 0; i < 3; i) {
rgb[i] = Math.round(color[i] * 255);
}
element.style.borderColor = Util.makeCssRgb(rgb);
element.style.borderStyle = 'solid';
var width = rect[2] - rect[0] - 2 * borderWidth;
var height = rect[3] - rect[1] - 2 * borderWidth;
element.style.width = width + 'px';
element.style.height = height + 'px';
element.data = this.data.src || '';
element.type = this.data.contentType || '';
return element;
}
});
return VideoAnnotation;
})();
41 changes: 41 additions & 0 deletions src/display/annotation_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,45 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
return container;
}

function getHtmlElementForVideoAnnotation(item) {
var container = initContainer(item)
container.className = 'annotVideo';

container.style.borderColor = item.colorCssRgb;
container.style.borderStyle = 'solid';

var contentType = item.contentType;
var element = document.createElement('video');
var checkSupport = element.canPlayType(contentType);
if (!checkSupport && (contentType in navigator.mimeTypes)) {
element = document.createElement('object');
element.data = item.src || '';
element.type = item.contentType || '';
var param = document.createElement('param');
param.name = 'controller';
param.value = true;
element.appendChild(param);
var param2 = document.createElement('param');
param2.name = 'uiMode';
param2.value = 'mini';
element.appendChild(param2);
} else if (checkSupport) {
// "maybe" and "probably"
element.src = item.src || '';
element.type = contentType || '';
element.poster = item.poster || '';
element.controls = true;
} else {
warn('Cant play the video, unsupported');
}

element.data = item.src || '';
element.type = item.contentType || '';

container.appendChild(element);
return container;
}

function getHtmlElement(data, objs) {
switch (data.annotationType) {
case AnnotationType.WIDGET:
Expand All @@ -240,6 +279,8 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
return getHtmlElementForTextAnnotation(data);
case AnnotationType.LINK:
return getHtmlElementForLinkAnnotation(data);
case AnnotationType.VIDEO:
return getHtmlElementForVideoAnnotation(data);
default:
throw new Error('Unsupported annotationType: ' + data.annotationType);
}
Expand Down
3 changes: 2 additions & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ var ImageKind = {
var AnnotationType = {
WIDGET: 1,
TEXT: 2,
LINK: 3
LINK: 3,
VIDEO: 4
};

var StreamType = {
Expand Down

0 comments on commit 19ce390

Please sign in to comment.