插入所需头文件路径,库路径以及相关库。在“nacl_sdk\pepper_49…”下。pepper_49中“49”是我安装的版本号。 4. 编译生成dll文件,以下是使用electron测试插件。 5. 测试: main.js
var app = require('app'); var BrowserWindow = require('browser-window'); var path = require('path') var mainWindow = null; app.commandLine.appendSwitch('register-pepper-plugins', path.join(__dirname, 'libppapi_hello.so;application/x-hello')) app.on('ready', function() { mainWindow = new BrowserWindow({ height: 800, width: 1024, 'web-preferences' : { 'pnacl.html
<!DOCTYPE html> <html> <!-- Copyright (c) 2013 The Chromium Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> <head> <title>hello_tutorial</title> <script type="text/javascript"> // The 'message' event handler. This handler is fired when the NaCl module // posts a message to the browser by calling PPB_Messaging.PostMessage() // (in C) or pp::Instance.PostMessage() (in C++). This implementation // simply displays the content of the message in an alert panel. function handleMessage(message_event) { alert(message_event.data); } </script> </head> <body> <h1>NaCl C++ Tutorial: Getting Started</h1> <p> <div id="listener"> <script type="text/javascript"> var listener = document.getElementById('listener'); listener.addEventListener('message', handleMessage, true); </script> <embed id="hello_tutorial" width=0 height=0 type="application/x-hello" /> </div> </p> </body> </html>package.json
{ "main": "main.js", "name": "Pepper plugin test", "description": "testing third party plugin load", "version": "0.0.1", "license": "MIT" }使用electron启动相关应用后可以看到,页面启动后弹出提示框。
