I have to add videos using javascript
I'm creating WPF application and reading html files, i added some javascript functions to files to be able to add multimedia files, the add of images amd audio works great but not for videos, here is the function add video:
function uiWebview_AddVideo()
{
//var xpathh=uiWebview_storeSelection();
var xpathh="/HTML[1]/BODY[1]/DIV[1]/P[1]/text()[1]|12|/HTML[1]/BODY[1]/DIV[1]/P[1]/text()[1]|22";
var videopath="C:\\Users\\Administrateur\\Desktop\\movie.mp4";
var index =1;
var annotguid="annotguid";
var annversion="annversion";
var auteursurname="auteursurname";
var foruserid=3;
var selectionDetails = xpathh;
selectionDetails = selectionDetails.split(/\|/g);
var range = document.createRange();
var selectionDetails0 = selectionDetails[0];
selectionDetails0 = selectionDetails0.replace(/\//g,"/h:");
selectionDetails0 = selectionDetails0.replace("h:t","t");
var selectionDetails2 = selectionDetails[2];
selectionDetails2 = selectionDetails2.replace(/\//g,"/h:");
selectionDetails2 = selectionDetails2.replace("h:t","t");
range.setStart(document.evaluate(selectionDetails0, document, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue, Number(selectionDetails[1]));
range.setEnd(document.evaluate(selectionDetails2, document, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue, Number(selectionDetails[3]));
//we create a SPAN element for every parts of matched keywords
var span = document.createElement("span");
var etoile = "*";
var text1 = document.createTextNode(auteursurname);
span.appendChild(text1);
//we create a p element for every parts of matched keywords
var p = document.createElement("aside");
p.setAttribute("class","video");
p.setAttribute("id",annotguid);
p.setAttribute("style","display:block;");
//*********** Video Tag ***********
var video = document.createElement("video");
video.innerHTML ="<video class=\"video-js\" width=\"640\" height=\"264\" controls preload poster=\"http://video-js.zencoder.com/oceans-clip.png\"><source src=\"C:\\Users\\Administrateur\\Desktop\\movie.mp4\" type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"' /><source src=\"C:\\Users\\Administrateur\\Desktop\\movie.webm\" type='video/webm; codecs=\"vp8, vorbis\"' /><source src=\"C:\\Users\\Administrateur\\Desktop\\movie.ogv\" type='video/ogg; codecs=\"theora, vorbis\"' /><object class=\"vjs-flash-fallback\" width=\"640\" height=\"264\" type=\"application/x-shockwave-flash\"data=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\"><param name=\"movie\" value=\"http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf\" /><param name=\"allowfullscreen\" value=\"true\" /><param name=\"flashvars\" value='config={\"playlist\":[\"http://video-js.zencoder.com/oceans-clip.png\", {\"url\": \"C:\\Users\\Administrateur\\Desktop\\movie.mp4\",\"autoPlay\":false,\"autoBuffering\":true}]}' /></object></video>";
//video.appendChild(object);
//***********************
p.appendChild(span);
var br = document.createElement("br");
p.appendChild(br);
p.appendChild(video);
var d = document.createElement("d");
d.appendChild(p);
//p.setAttribute("class","bubble speech");
var obj = range.startContainer;
while (obj.nodeName.toLowerCase() != 'p' && obj.nodeName.toLowerCase() != 'table'
&& obj.nodeName.toLowerCase() != 'p' && obj.nodeName.toLowerCase() != 'address'
&& obj.nodeName.toLowerCase() != 'body' && obj.nodeName.toLowerCase() != 'body') {
obj = obj.parentNode;
}
if (obj.nodeName.toLowerCase() == 'p' || obj.nodeName.toLowerCase() == 'table'
|| obj.nodeName.toLowerCase() == 'p' || obj.nodeName.toLowerCase() == 'address'
|| obj.nodeName.toLowerCase() == 'p' || obj.nodeName.toLowerCase() == 'p') {
obj.parentNode.insertBefore(d, obj);
}
else {
obj = range.commonAncestorContainer;
obj.parentNode.insertBefore(d, obj);
}
//we create a A element for every parts of matched keywords
var a = document.createElement("a");
var etoile = "*";
var text2 = document.createTextNode(etoile.concat(index).concat(" "));
a.appendChild(text2);
var chaine1="javascript:changestyledisplayblock('";
var chaine2="')";
var hre=(chaine1.concat(annotguid)).concat(chaine2);
a.setAttribute("class", "marker");
a.setAttribute("href", hre);
a.setAttribute("style", "color:#004080;text-decoration:underline");
range.insertNode(a);
return;
}
I found many other flash players but it seems that they don't work in my webbrowser (IE7) I'm looking for indication to a player that would garantie the add of video Or an alternative to resolve the error that display the flash "201 unable to load stream or clip file try loosening flash security setting error #2148" and thanks
You can use the Media player controle by drag and drop (Winforms solution) http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
Or adding a new tag embed wich contains the video/audio also using Media player
var embed = document.createElement("embed");
embed.setAttribute("type", "application/x-mplayer2");
embed.setAttribute("pluginspage", "http://www.microsoft.com/Windows/MediaPlayer");
embed.setAttribute("src", videoSource);
This solution worked for me ;)