Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2129410
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2010-03-24 11:25:03

    I need vlc firefox plugin to receive remote control signals and show some OSD notification(Using libnotify in shell or python),but javascript cannot call function in other programming language(scripts) like C、shell、python.I wonder is that possible modifying or adding javascript API for vlc? If yes,I can realize the OSD notification function in Javascript APIs and show some useful messages or pictures.

    In my opinion,vlc firefox plugin is the bridge between browser and the system,javascript can receive the remote control signal and show some message through the vlc plugin embedded in the firefox browser.

    Vlc webplugin APIs was realized in vlc/project/mozilla/control/npolibvlc.cpp,you can modify some APIs.Trace the source code,you will find libvlc APIs(or some functions realized in vlc/project/mozilla/vlcplugin.cpp) were used in fact.So,add a method of exist object that is not offered by now,and look at Reference 2 for details.

Example
Now we will add a method of audio object that can be used directly in javascript like vlc.audio.volumeUp.

vlc/project/mozilla/control/npolibvlc.cpp

const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
{
    "toggleMute",
    "description",
    "volumeUp",
};


add a case statement to function
RuntimeNPObject::InvokeResult
LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
                            uint32_t argCount, NPVariant &result)

case ID_audio_volumeup:
                if( argCount == 0 )
                {
                    int vol_up = p_plugin->volume_up_32();
                    libvlc_audio_set_volume(p_md,vol_up);
                    VOID_TO_NPVARIANT(result);
                    return INVOKERESULT_NO_ERROR;
                }
                return INVOKERESULT_NO_SUCH_METHOD;


Realize volume_up_32() function in file project/mozilla/vlcplugin.cpp

int VlcPlugin::volume_up_32()
{
    int cur_vol;
    cur_vol = libvlc_audio_get_volume(libvlc_media_player) + 32;
    return cur_vol;
}


All's done,make and write a javascript to test it.


Have a try
djstava

References:
1、VLC Javascript API
2、Libvlc API
阅读(3503) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~