我希望實現類似於Facebook中的功能,您可以在其中發佈視頻。所以,當你複製鏈接時,Facebook創建某種快照,然後你發佈它。我搜索谷歌如何做到這一點,但不幸的是沒有遇到任何有用的東西。如何實現Facebook中的後期視頻功能
我想知道是否有一些已經實現的插件或教程來執行此類操作。
我發現的唯一例子就像下面使用標記的jQuery庫。除此之外還有更優雅的東西嗎?
marked.setOptions({
gfm: true,
pedantic: false,
sanitize: true,
highlight: null,
urls: {
youtube : function(text, url) {
var cap;
if((cap = /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/.exec(url))) {
return '<iframe width="420" height="315" src="https://www.youtube.com/embed/' + cap[5] + '" frameborder="0" allowfullscreen</iframe>';
}
},
vimeo : function(text, url) {
var cap;
if((cap = /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/.exec(url))) {
return '<iframe src="https://player.vimeo.com/video/' + cap[5] +'" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
}
},
dailymotion : function(text, url) {
var cap;
if((cap = /^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/.exec(url))) {
return '<iframe frameborder="0" width="480" height="271" src="https://www.dailymotion.com/embed/video/' + cap[2] +'"></iframe>';
}
}
});