I'm getting an error from mediaelement-and-player.min.js:
Line: 44 Error: Unexpected call to method or property access.
I'm trying to use the player in a webpart in Sharepoint 2010. The example I'm trying out is the YouTube example.
Here are my code snippets cut out from the webpart.
jQuery is loaded by the masterpage in SP2010.
Loading plugins:
this.Controls.Add(new CssRegistration() { Name = "/_layouts/Script/mediaelement/mediaelementplayer.css", EnableCssTheming = true });
this.Controls.Add(new ScriptLink { Name = "/_layouts/Script/mediaelement/mediaelement-and-player.min.js", Language = "javascript", Localizable = false, LoadAfterUI = true });
this.Controls.Add(new ScriptLink { Name = "/_layouts/Script/video.js", Language = "javascript", Localizable = false, LoadAfterUI = true });
HTML code:
writer.Write("<video width='320' height='240' id='player1' >");
writer.Write(" <!-- Pseudo HTML5 -->");
writer.Write(" <source src='" + VideoPickerUrl + "' type='video/youtube' />");
writer.Write("</video>");
writer.Write("<span id='player1-mode'></span>");
Javascript code:
$("video").mediaelementplayer({
enablePluginDebug: true,
pluginPath: '/_layouts/Script/mediaelement/',
flashName: 'flashmediaelement.swf',
success: function (media, node, player) {
$('#' + node.id + '-mode').html('mode: ' + media.pluginType);
},
error: function () {
$('#' + node.id + '-mode').html('Noe er feil!');
}
});
Edit:
When trying the NOT .min js file, I'm also getting the error on line 970. The code stops at the if statement:
for (i=0; i<mediaFiles.length; i++) {
// normal check
if (htmlMediaElement.canPlayType(mediaFiles[i].type).replace(/no/, '') !== ''
// special case for Mac/Safari 5.0.3 which answers '' to canPlayType('audio/mp3') but 'maybe' to canPlayType('audio/mpeg')
|| htmlMediaElement.canPlayType(mediaFiles[i].type.replace(/mp3/,'mpeg')).replace(/no/, '') !== '') {
result.method = 'native';
result.url = mediaFiles[i].url;
break;
}
}
Do you have any tips on what I'm doing wrong?
Best regards
Anders