| author | veltr |
| Fri, 23 Nov 2012 19:13:50 +0100 | |
| changeset 49 | a21b851538b2 |
| parent 45 | f39df810caab |
| child 50 | 89e152523cb6 |
| permissions | -rw-r--r-- |
| 49 | 1 |
IriSP.mashupplayer = function(options) { |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
2 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
3 |
var directory = new IriSP.Model.Directory(), |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
4 |
project = directory.remoteSource({ |
| 49 | 5 |
url: IriSP.endpoints.ldt + options.id, |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
6 |
serializer: IriSP.serializers.ldt |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
7 |
}), |
| 49 | 8 |
apidirectory = new IriSP.Model.Directory(), |
| 43 | 9 |
mashup, |
10 |
mediatemplate = _.template('<li class="item-video media" data-media-id="<%= media.id %>">' |
|
| 49 | 11 |
+ '<a href="<%= IriSP.endpoints.media_page + media.id %>"><img class="thumbnail" alt="<%= media.title %>" src="<%= media.thumbnail %>"></a><div class="video-info">' |
| 43 | 12 |
+ '<h3 class="title-video"><a href="#"><%= media.title %></a></h3><p class="description"><%= media.description %></p>' |
13 |
+ '<p class="time-length">Durée : <span><%= media.duration.toString() %></span></p><div class="frise">' |
|
14 |
+ '<div class="frise-overflow"><div class="frise-segments"><%= segments %></div></div></div></div></li>'); |
|
15 |
segmenttemplate = _.template('<div style="background-color:<%= annotation.color %>; left:<%= left %>%; width: <%= width %>%;"' |
|
16 |
+ ' class="frise-segment annotation" data-segment-id="<%= annotation.id %>" title="<%= annotation.title %>"></div>') |
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
17 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
18 |
project.onLoad(function() { |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
19 |
mashup = project.getMashups()[0]; |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
20 |
IriSP.mashupcore(project, mashup); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
21 |
project.trigger("set-current",mashup); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
22 |
|
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
23 |
$(".info-title a").text(mashup.title); |
| 49 | 24 |
$(".title-video-wrap .title-video").text(mashup.title); |
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
25 |
$(".info-duration td").text(mashup.duration.toString()); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
26 |
$(".info-author a").text(mashup.creator); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
27 |
$(".info-description td").text(mashup.description); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
28 |
|
| 43 | 29 |
mashup.getMedias().forEach(function(media) { |
| 49 | 30 |
apidirectory.remoteSource({ |
31 |
url: IriSP.endpoints.content + media.id, |
|
32 |
serializer: IriSP.serializers.content |
|
33 |
}).onLoad(function() { |
|
34 |
var m = apidirectory.getElement(media.id); |
|
35 |
if (m) { |
|
36 |
media.thumbnail = m.thumbnail; |
|
37 |
} |
|
38 |
var segments = mashup.segments.filter(function(segment) { |
|
39 |
return segment.getMedia() === media; |
|
40 |
}); |
|
41 |
var segmentshtml = '', k = media.duration ? (100 / media.duration) : 0; |
|
42 |
segments.forEach(function(segment) { |
|
43 |
var vizdata = { |
|
44 |
annotation: segment.annotation, |
|
45 |
left: k * segment.annotation.begin, |
|
46 |
width: k * segment.annotation.getDuration() |
|
47 |
} |
|
48 |
segmentshtml += segmenttemplate(vizdata); |
|
49 |
}); |
|
50 |
var mediadata = { |
|
51 |
media: media, |
|
52 |
segments: segmentshtml |
|
53 |
} |
|
54 |
|
|
55 |
$(".list-video").append(mediatemplate(mediadata)); |
|
| 43 | 56 |
}); |
57 |
}); |
|
58 |
|
|
59 |
|
|
60 |
project.on("mouseover-annotation", function(annotation) { |
|
61 |
var mediaid = annotation.getMedia().id; |
|
62 |
$(".media").removeClass("active"); |
|
63 |
$(".media[data-media-id='" + mediaid + "']").addClass("active"); |
|
64 |
}); |
|
65 |
|
|
66 |
project.on("mouseout-annotation", function(annotation) { |
|
67 |
$(".media").removeClass("active"); |
|
68 |
var mediaid = mashup.currentMedia.id; |
|
69 |
$(".media[data-media-id='" + mediaid + "']").addClass("active"); |
|
70 |
}); |
|
71 |
|
|
| 49 | 72 |
$(".list-video") |
73 |
.on("mouseover", ".frise-segment", function() { |
|
| 43 | 74 |
project.trigger("mouseover-annotation", project.getElement($(this).attr("data-segment-id"))); |
75 |
}) |
|
| 49 | 76 |
.on("click", ".frise-segment", function() { |
| 43 | 77 |
project.trigger("click-annotation", project.getElement($(this).attr("data-segment-id"))); |
| 49 | 78 |
}) |
79 |
.on("mouseover", ".item-video", function() { |
|
| 43 | 80 |
$(".media").removeClass("active"); |
81 |
}) |
|
| 49 | 82 |
.on("mouseout", ".item-video", function() { |
| 43 | 83 |
project.trigger("mouseout-annotation"); |
84 |
}) |
|
85 |
|
|
86 |
|
|
|
41
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
87 |
}); |
|
3ec2343f2b85
Refactoring to have common code between editor and player
veltr
parents:
diff
changeset
|
88 |
} |