? simple
? examples/MediaPlayer/build
? examples/MediaPlayer/build.properties
? examples/MediaPlayer/build.properties.sample
? test/build
M examples/MediaPlayer/JMPlayer.java
M examples/MediaPlayer/build.xml
M examples/MediaPlayer/samples/test.html
M mozilla/nppluglet.cpp
M mozilla/nppluglet.h
This commit is contained in:
edburns%acm.org 2006-10-23 05:18:19 +00:00
Родитель ed83279f15
Коммит 2e2a758b41
6 изменённых файлов: 153 добавлений и 30 удалений

Просмотреть файл

@ -18,7 +18,14 @@ public class JMPlayer implements PlugletFactory {
public JMPlayer() {
}
public Pluglet createPluglet(String mimeType) {
return new Player();
Pluglet player = null;
try {
player = new Player();
}
catch (Throwable e) {
System.out.println("debug: edburns: " + e.getMessage());
}
return player;
}
public void initialize(PlugletManager manager) {
}

Просмотреть файл

@ -0,0 +1,3 @@
jmf.home=D:\\Files_2k\\JMF2.1.1e
jmf.jar=${jmf.home}/lib/jmf.jar
sound.jar=${jmf.home}/lib/sound.jar

Просмотреть файл

@ -59,6 +59,7 @@
<!-- Construct compile classpath -->
<path id="compile.classpath">
<pathelement location="${build.home}"/>
<pathelement location="${jmf.jar}"/>
</path>
<target name="prepare">
@ -100,10 +101,10 @@
<jar jarfile="${basedir}/build/mediaplayer.jar">
<manifest>
<attribute name="MIMEDescription" value="video/avi"/>
<attribute name="Pluglet-Class" value="test"/>
<attribute name="Pluglet-Class" value="JMPlayer"/>
</manifest>
<fileset dir="${basedir}/build">
<include name="*.class" />
<include name="**/*.*" />
</fileset>
</jar>

Просмотреть файл

@ -1,5 +0,0 @@
<html>
<body>
<EMBED type="video/avi" name=JMPlayer SRC="tilego3.avi" width=400 height=400>
</body>
</html>

Просмотреть файл

@ -44,6 +44,8 @@
#include "nsIServiceManager.h"
#include "nsIMemory.h"
#include "nsISupportsUtils.h" // this is where some useful macros defined
#include "ns4xPluginStreamListener.h"
#include "nsIPluginStreamInfo.h"
#include "nsServiceManagerUtils.h"
@ -214,30 +216,16 @@ NPBool nsPluginInstance::init(NPWindow* aWindow)
return mInitialized;
}
rv = mPluglet->Initialize(peer);
#if defined(XP_MAC) || defined(XP_MACOSX)
#elif defined(XP_WIN) || defined(XP_OS2)
pluginWindow.window = (nsPluginPort *) aWindow->window;
#elif defined(XP_UNIX) && defined(MOZ_X11)
#else
#endif
pluginWindow.x = aWindow->x;
pluginWindow.y = aWindow->y;
pluginWindow.width = aWindow->width;
pluginWindow.height = aWindow->height;
pluginWindow.clipRect.top = aWindow->clipRect.top;
pluginWindow.clipRect.left = aWindow->clipRect.left;
pluginWindow.clipRect.bottom = aWindow->clipRect.bottom;
pluginWindow.clipRect.right = aWindow->clipRect.right;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
pluginWindow.ws_info = aWindow->ws_info;
#endif
pluginWindow.type = aWindow->type == NPWindowTypeWindow ?
nsPluginWindowType_Window : nsPluginWindowType_Drawable;
rv = mPluglet->SetWindow(&pluginWindow);
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->Start();
rv = this->CopyNPWindowToNsPluginWindow(aWindow, &pluginWindow);
if (NS_SUCCEEDED(rv)) {
mInitialized = PR_TRUE;
rv = mPluglet->Start();
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->SetWindow(&pluginWindow);
if (NS_SUCCEEDED(rv)) {
mInitialized = PR_TRUE;
}
}
}
}
@ -258,6 +246,90 @@ NPBool nsPluginInstance::isInitialized()
return mInitialized;
}
NPError nsPluginInstance::SetWindow(NPWindow* pNPWindow)
{
nsresult rv = NS_ERROR_FAILURE;
nsPluginWindow pluginWindow;
if (!this->isInitialized()) {
return rv;
}
rv = this->CopyNPWindowToNsPluginWindow(pNPWindow, &pluginWindow);
if (NS_SUCCEEDED(rv)) {
rv = mPluglet->SetWindow(&pluginWindow);
}
return (NPError) rv;
}
NPError nsPluginInstance::NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype)
{
nsresult rv = NS_ERROR_FAILURE;
if (!this->isInitialized()) {
return rv;
}
nsCOMPtr<nsIPluginStreamListener> listener = nsnull;
rv = mPluglet->NewStream(getter_AddRefs(listener));
if (NS_SUCCEEDED(rv)) {
ns4xPluginStreamListener * hostListener =
(ns4xPluginStreamListener *) stream->ndata;
if (hostListener) {
nsCOMPtr<nsIPluginStreamInfo> hostStreamInfo =
hostListener->mStreamInfo;
if (hostStreamInfo) {
rv = listener->OnStartBinding(hostStreamInfo);
if (NS_SUCCEEDED(rv)) {
stream->pdata = (void *) listener.get();
nsCOMPtr<nsISupports> toCast =
do_QueryInterface(listener);
nsISupports *toAddRef = (nsISupports *) toCast.get();
NS_ADDREF(toAddRef);
}
}
}
}
return rv;
}
NPError nsPluginInstance::DestroyStream(NPStream *stream, NPError reason)
{
nsresult rv = NS_ERROR_FAILURE;
if (!this->isInitialized()) {
return rv;
}
nsCOMPtr<nsIPluginStreamListener> listener =
(nsIPluginStreamListener *) stream->pdata;
nsCOMPtr<nsISupports> toCast = do_QueryInterface(listener);
nsISupports *toRelease = (nsISupports *) toCast.get();
NS_RELEASE(toRelease);
listener = nsnull;
stream->pdata = nsnull;
return NS_OK;
}
int32 nsPluginInstance::WriteReady(NPStream *stream) {
int32 result = 65536;
return result;
}
int32 nsPluginInstance::Write(NPStream *stream, int32 offset,
int32 len, void *buffer)
{
int32 result = len;
nsCOMPtr<nsIPluginStreamListener> listener =
(nsIPluginStreamListener *) stream->pdata;
return result;
}
NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
PRBool *outResult)
{
@ -288,6 +360,39 @@ NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
return rv;
}
nsresult nsPluginInstance::CopyNPWindowToNsPluginWindow(NPWindow *aWindow,
nsPluginWindow *pluginWindow)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (nsnull == aWindow || nsnull == pluginWindow) {
return rv;
}
#if defined(XP_MAC) || defined(XP_MACOSX)
#elif defined(XP_WIN) || defined(XP_OS2)
pluginWindow->window = (nsPluginPort *) aWindow->window;
#elif defined(XP_UNIX) && defined(MOZ_X11)
#else
#endif
pluginWindow->x = aWindow->x;
pluginWindow->y = aWindow->y;
pluginWindow->width = aWindow->width;
pluginWindow->height = aWindow->height;
pluginWindow->clipRect.top = aWindow->clipRect.top;
pluginWindow->clipRect.left = aWindow->clipRect.left;
pluginWindow->clipRect.bottom = aWindow->clipRect.bottom;
pluginWindow->clipRect.right = aWindow->clipRect.right;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
pluginWindow->ws_info = aWindow->ws_info;
#endif
pluginWindow->type = aWindow->type == NPWindowTypeWindow ?
nsPluginWindowType_Window : nsPluginWindowType_Drawable;
rv = NS_OK;
return rv;
}
// ==============================

Просмотреть файл

@ -53,6 +53,15 @@ public:
void shut();
NPBool isInitialized();
NPError SetWindow(NPWindow* pNPWindow);
NPError NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype);
NPError DestroyStream(NPStream *stream, NPError reason);
int32 WriteReady(NPStream *stream);
int32 Write(NPStream *stream, int32 offset, int32 len, void *buffer);
// we need to provide implementation of this method as it will be
// used by Mozilla to retrive the scriptable peer
// and couple of other things on Unix
@ -70,6 +79,9 @@ private:
nsScriptablePeer * mScriptablePeer;
nsPluginCreateData mCreateDataStruct;
nsresult CopyNPWindowToNsPluginWindow(NPWindow *npWindow,
nsPluginWindow *nsWindow);
public:
char mString[128];
};