| author | veltr |
| Mon, 06 May 2013 16:12:54 +0200 | |
| changeset 146 | fb46a25a9d06 |
| parent 123 | 679809037606 |
| child 154 | 60ca7678f074 |
| permissions | -rw-r--r-- |
| 49 | 1 |
IriSP.mediaplayer = function(options) { |
2 |
|
|
3 |
var directory = new IriSP.Model.Directory(), |
|
4 |
content = directory.remoteSource({ |
|
5 |
url: IriSP.endpoints.content + options.id, |
|
6 |
serializer: IriSP.serializers.content |
|
7 |
}), |
|
| 50 | 8 |
apidirectory = new IriSP.Model.Directory(), |
9 |
segmenttemplate = _.template( |
|
10 |
'<div class="media-segment" data-mashup-id="<%= annotation.project_id %>">' |
|
11 |
+ '<div class="media-segment-section" style="left:<%= left %>px; width:<%= width %>px; background:<%= color %>; top: <%= top %>px;" data-segment-id="<%= annotation.id %>"></div>' |
|
| 65 | 12 |
+ '<div class="popin media-segment-popin" style="left:<%= popleft %>px; top: <%= 5+top %>px;"><div style="left:<%= pointerpos %>px;" class="pointer"></div><div class="popin-content">' |
|
123
679809037606
Changes in video handling, displayed metadata and search results
veltr
parents:
109
diff
changeset
|
13 |
+ '<h3 class="segment-title"><%= annotation.title %></h3>' |
|
679809037606
Changes in video handling, displayed metadata and search results
veltr
parents:
109
diff
changeset
|
14 |
+ '<p><%= annotation.description %></p><% if (annotation.keywords.length) { print("<p><strong>" + gettext("Tags:") + "</strong> " + annotation.keywords.join(", ") + "</p>"); } %>' |
| 104 | 15 |
+ '<p><%= gettext("From:") %> <span><%= annotation.begin.toString() %></span> <%= gettext("to:") %> <span><%= annotation.end.toString() %></span> (<%= gettext("duration:") %> <span><%= annotation.getDuration().toString() %></span>)</p>' |
| 109 | 16 |
+ '<p class="mashup-link"><%= gettext("From hashcut:") %> <a href="<%= IriSP.endpoints.hashcut_page.replace("__PROJECT_ID__", annotation.project_id) %>"></a></p>' |
| 50 | 17 |
+ '</div></div></div>' |
18 |
), |
|
19 |
segmentlisttemplate = _.template( |
|
20 |
'<div class="media-segment-list" style="height: <%= height %>px"><div class="media-segment-list-inner"></div><%= segments %><div class="frise-position"></div></div>' |
|
21 |
), |
|
22 |
projtemplate = _.template( |
|
23 |
'<li class="item-video mashup" data-mashup-id="<%= ldt_id %>">' |
|
| 109 | 24 |
+ '<a href="<%= IriSP.endpoints.hashcut_page.replace("__PROJECT_ID__", ldt_id) %>"><img class="thumbnail" alt="<%= title %>" src="<%= image %>"></a><div class="video-info">' |
25 |
+ '<h3 class="title-video"><a href="<%= IriSP.endpoints.hashcut_page.replace("__PROJECT_ID__", ldt_id) %>"><%= title %></a></h3><p class="description"><%= description %></p>' |
|
| 50 | 26 |
+ '</p></div></li>' |
27 |
), |
|
28 |
media; |
|
29 |
|
|
30 |
function mediaSegmentList(_annotations) { |
|
31 |
var html = '', |
|
32 |
k = $(".Ldt-Slider").width() / media.duration, |
|
33 |
lines = []; |
|
34 |
_(_annotations).each(function(_a, i) { |
|
35 |
var pos = k * (_a.begin + _a.end) / 2, |
|
36 |
corrpos = Math.max(106, Math.min(516, pos)), |
|
37 |
line = IriSP._(lines).find(function(line) { |
|
38 |
return !IriSP._(line.annotations).find(function(ann) { |
|
39 |
return ann.begin < _a.end && ann.end > _a.begin |
|
40 |
}); |
|
41 |
}); |
|
42 |
if (!line) { |
|
43 |
line = { index: lines.length, annotations: []}; |
|
44 |
lines.push(line); |
|
45 |
} |
|
46 |
line.annotations.push(_a); |
|
47 |
vizdata = { |
|
48 |
annotation : _a, |
|
49 |
popleft : corrpos, |
|
50 |
left : k * _a.begin, |
|
51 |
width : k * _a.getDuration(), |
|
52 |
height: 8, |
|
53 |
top: 8 * line.index, |
|
54 |
pointerpos : (pos - corrpos), |
|
55 |
color: IriSP.vizcolors[i % IriSP.vizcolors.length] |
|
56 |
} |
|
57 |
html += segmenttemplate(vizdata); |
|
58 |
}); |
|
59 |
return segmentlisttemplate({ |
|
60 |
height: 8 * lines.length, |
|
61 |
segments: html |
|
62 |
}); |
|
63 |
} |
|
| 49 | 64 |
|
65 |
content.onLoad(function() { |
|
66 |
|
|
67 |
IriSP.mashupcore(content, new IriSP.Model.Mashup(false, content)); |
|
68 |
|
|
| 50 | 69 |
media = content.getMedias()[0]; |
| 49 | 70 |
|
| 50 | 71 |
apidirectory.remoteSource({ |
72 |
url: IriSP.endpoints.segment, |
|
73 |
url_params: { |
|
74 |
iri_id: options.id, |
|
75 |
limit: 0 |
|
76 |
}, |
|
77 |
serializer: IriSP.serializers.segmentapi |
|
78 |
}).onLoad(function() { |
|
79 |
var medias = this.getMedias(), |
|
80 |
annotations = this.getAnnotations(), |
|
81 |
projlist = {}; |
|
82 |
$(".media-segments").html(mediaSegmentList(annotations)); |
|
83 |
annotations.forEach(function(a) { |
|
84 |
projlist[a.project_id] = 1 + (projlist[a.project_id] || 0); |
|
85 |
}); |
|
86 |
var projkeys = _(projlist) |
|
87 |
.chain() |
|
88 |
.keys() |
|
89 |
.sortBy(function(v) { |
|
90 |
return - projlist[v]; |
|
91 |
}) |
|
92 |
.first(8) |
|
93 |
.value(); |
|
94 |
$.ajax({ |
|
95 |
url: IriSP.endpoints.project, |
|
96 |
dataType: "json", |
|
97 |
data: { |
|
98 |
format: "json", |
|
99 |
ldt_id__in: projkeys |
|
100 |
}, |
|
101 |
traditional: true, |
|
102 |
success: function(data) { |
|
103 |
var proj = _(data.objects) |
|
104 |
.filter(function(p) { |
|
105 |
return /<inst/gm.test(p.ldt); |
|
106 |
}); |
|
107 |
_(proj).each(function(p) { |
|
108 |
$(".media-segment[data-mashup-id='" + p.ldt_id + "']").each(function() { |
|
109 |
$(this) |
|
110 |
.find(".mashup-link").show() |
|
111 |
.find("a").text(p.title); |
|
112 |
}); |
|
113 |
}); |
|
114 |
var html = _(proj) |
|
115 |
.chain() |
|
116 |
.sortBy(function(p) { |
|
117 |
return - projlist[p.ldt_id]; |
|
118 |
}) |
|
119 |
.map(projtemplate) |
|
120 |
.value() |
|
121 |
.join(""); |
|
122 |
$(".list-video").html(html); |
|
123 |
} |
|
124 |
}); |
|
125 |
}); |
|
126 |
|
|
| 49 | 127 |
content.trigger("set-current", media); |
128 |
|
|
129 |
$(".info-duration td").text(media.duration.toString()); |
|
130 |
$(".info-description td").text(media.description); |
|
131 |
$(".info-tags td").text(media.keywords); |
|
132 |
|
|
133 |
}); |
|
| 50 | 134 |
|
135 |
$(".media-segments").on("mouseover", ".media-segment", function() { |
|
136 |
var el = $(this); |
|
137 |
el.find(".media-segment-popin").show(); |
|
138 |
var pid = el.attr("data-mashup-id"); |
|
139 |
$(".item-video[data-mashup-id='" + pid + "']").addClass("active"); |
|
140 |
}).on("mouseout", ".media-segment", function() { |
|
141 |
$(this).find(".media-segment-popin").hide(); |
|
142 |
$(".item-video").removeClass("active"); |
|
143 |
}).on("click", ".media-segment-section", function() { |
|
144 |
var sid = $(this).attr("data-segment-id"), |
|
145 |
s = apidirectory.getElement(sid); |
|
146 |
media.setCurrentTime(s.begin); |
|
147 |
}); |
|
148 |
|
|
149 |
$(".list-video").on("mouseover", ".item-video", function() { |
|
150 |
var pid = $(this).attr("data-mashup-id"); |
|
151 |
$(".media-segment[data-mashup-id='" + pid + "']").addClass("active"); |
|
152 |
}).on("mouseout", ".item-video", function() { |
|
153 |
$(".media-segment").removeClass("active"); |
|
154 |
}); |
|
| 49 | 155 |
} |
| 50 | 156 |
|
157 |
/* END mediaplayer.js */ |
|
158 |