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