Analyze video webpage, and display video url in a box.
You can play HLS(m3u8) in Chrome by HLSPlayer extention.
Video providers.
| LOGO | Name | Site | Condition |
| 音悦Tai | yinyuetai.com | mp4 | |
![]() | 优酷 | youku.com | flv或mp4片段列表 + m3u8(不能拖动进度) |
![]() | 芒果tv | mgtv.com | m3u8(能拖动进度) |
![]() | 搜狐视频 | tv.sohu.com | mp4片段列表 |
![]() | 腾讯视频 | v.qq.com | ... |
![]() | 56 | 56.com | ... |
Video right menu send to native video player.
http://match-yang.blog.163.com/blog/static/2109902542014319103739996/
http://blog.csdn.net/ztmaster/article/details/52684772
1.Chrome Extension Support
manifest.json "permissions": [ "nativeMessaging" ]
var port = null;
var nativeHostName = "videograb";
function onDisconnected(){
console.log( "Disconnect " + chrome.runtime.lastError.message);
port = null;
}
function connectToNativeHost(){
port = chrome.runtime.connectNative(nativeHostName);
port.onDisconnect.addListener(onDisconnected);
}
chrome.contextMenus.create({
"id" : "CMVideoGrab",
"title" : "播放视频",
"contexts" : ["video","link"]
});
chrome.contextMenus.onClicked.addListener(function(info, tab){
//console.log(info);
if(info.menuItemId == 'CMVideoGrab'){
connectToNativeHost();
console.log(info.srcUrl);
port.postMessage(info.srcUrl);
}
});
2.Software Receive Parameters
Qt(C++)
QMediaPlayer *player;
QStringList Largs = QApplication::arguments();
qDebug() << Largs;
if(Largs.length()>1){
if(!Largs.at(1).contains("chrome-extension://")){
QUrl url(Largs.at(1));
open(url.toLocalFile());
}else{
int length = 0;
//read the first four bytes (=> Length)
//getwchar: receive char from stdin
//putwchar: write char to stdout
for (int i = 0; i < 4; i++) {
length += getwchar();
}
//read the json-message
QString url = "";
for (int i = 0; i < length; i++) {
url += getwchar();
}
//浏览器端传来的数据会有一个双引号引在两端
url = url.mid(1, url.length()-2);
qDebug() << url;
if(url != ""){
ui->tableWidget->hide();
player->setMedia(QUrl(url));
player->play();
setWindowTitle(url);
}
}
3.Config file
path: Software absolute path
allowed_origins: chrome-extension://*
videograb.json
{
"name": "videograb",
"description": "Chrome send video url to native app.",
"path": "/media/sonichy/job/HY/Linux/Qt/HTYMP/HTYMP",
"type": "stdio",
"allowed_origins": [ "chrome-extension://jiahehpnnhnnohoaknibedkbkdkibeho/" ]
}
Linux Path:~/.config/google-chrome/NativeMessagingHosts
Windows运行:REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\videograb" /ve /t REG_SZ /d "%~dp0videograb.json" /f





