This project is read-only.

Issues with the video commenting system (and a solution)

Jan 28, 2008 at 4:28 PM
Edited Jan 28, 2008 at 4:30 PM

When I make a comment, some strange issue are happening to me: the javascript is failing to access the comments in the Silverlight video control (I have Silverlight 1.1 installed).
The error, when debugging indicates that it fails as a Null is assigned to the “comment” object in the resetCommentWindow function.

I have debugged it and here is the code with some comments from me:

resetCommentWindow: function() {
var marker;
var comment;
var totalHeight = 0;
var commentBuffer = 30;
var commentsCanvas = this._rootElement.findName('CommentsCanvas');

for (var i = 0; i < this._numComments; i++) { <<<< this goes through all the comments…
marker = this.GetMarker(i);
var commentId = parseInt(marker.Type,10); <<<< For some reason the marker that fails gets the value “Narration Note” and not a number, so it can’t convert it… causing that commentId to equal NaN (Not a Number)
comment = this.GetCommentById(commentId); <<<< Obviously this results in Null

if (i === 0) {

if (this._numComments > 1) {
comment.findName('CommentText_' + commentId).Text = 'Comments:';
commentsCanvas'Canvas.Top' = (commentsCanvas.Height / 2) - comment.Height;
comment'Canvas.Top' = 0;
totalHeight += comment.Height + commentBuffer;
} else {
comment'Canvas.Top' = totalHeight; <<<< No Null validation, so it breaks here…
totalHeight += comment.Height + commentBuffer;

var loadingMessage = this._rootElement.findName('LoadingMessage');
loadingMessage.Visibility = 'Collapsed';


I have corrected the code but the changes I made doesn’t get applied to the already uploaded videos (as they are uploaded with the js code mentioned, too), so they have to be deleted.
The code file is located at the Web project, concretely on /Web/Silverlight/Player/Player.js

And the changes I made are these: Not the best solution but it works for me:

for (var i = 0; i < this._numComments; i++) {
marker = this.GetMarker(i);
var commentId = parseInt(marker.Type,10);

/* JL Modifications to correct commenting system */
if ( isNaN(commentId) ) {
commentId = i; <<<<<<< The times it works well, it gets a correspondance with the id number so I pass it directly in case the commentId is NaN...

comment = this.GetCommentById(commentId);

Hope that helps somebody with the same problem.