I have to add videos using javascript
我正在创建WPF应用程序和阅读html文件,我添加了一些javascript函数到文件,以便能够添加多媒体文件,添加图像和音频效果很好但不适用于视频,这里是功能添加视频:< / p>
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;
}
我找到了很多其他的flash播放器,但似乎它们在我的webbrowser(IE7)中不起作用 我正在寻找能够保证添加视频的播放器的指示 或者替代解决显示闪存的错误“201无法加载流或剪辑文件尝试放松闪存安全设置错误#2148” 并谢谢
答案 0 :(得分:0)
您可以通过拖放(Winforms解决方案)使用媒体播放器控制 http://msdn.microsoft.com/en-us/library/bb383953(v=vs.90).aspx
或者使用媒体播放器
添加包含视频/音频的新标签 var embed = document.createElement("embed");
embed.setAttribute("type", "application/x-mplayer2");
embed.setAttribute("pluginspage", "http://www.microsoft.com/Windows/MediaPlayer");
embed.setAttribute("src", videoSource);
此解决方案对我有用;)