Main > Audio/Jukebox/MP3 Forum
Plugins: Document API for JukePlugSys
headkaze:
--- Quote from: unclet on January 08, 2008, 07:58:51 pm ---2) How does the plugin send information back to the jukebox software? Does the jukebox software have to do anything special to check whether a the plugin has sent it information?
--- End quote ---
It just returns information when you send a command.
Eg.
--- Code: ---Dim mp3Tag() As String
mp3Tag = Juke_Command("JUKE_GET_MP3_TAG", "C:\Music\MySong.mp3")
MsgBox "SongName:" & mp3Tag(0) & "Album:" & mp3Tag(1)
--- End code ---
If you want to be able to receive data from the plugin at any time create a timer and put in a special command that is sent over every 2 seconds to check for data
Eg. Juke_Command("JUKE_DATA_CHECK_TIMER", "STATUS")
Then you can check for data from the plugin and the plugin can send it over whenever it wants to. But I don't really see a need for such a thing, do you?
--- Quote from: unclet on January 08, 2008, 07:58:51 pm ---3) Why do we need more than these two routines?
Juke_GetPluginInfo()
Juke_PluginCommand()
*snip*
--- End quote ---
Because it's just standard programming practice to do it that way. I know you could put everything into a command and have one magic function called Juke_Command() that does everything. But these are important functions that every plugin needs therefore it's my opinion they should be in there to make it clear to the plugin coder they must contain the initialization and shutdown code.
All plugin systems need to have that, so I think they should have functions of their own. Now we can just accept this and move on or debate it until our heads turn blue. It's really not an important thing to be concerned about, all the code is already written to support it now anyway. It's best to just finalize the basic plugin structure now and move on to the more important Jukebox commands.
--- Quote from: unclet on January 08, 2008, 07:58:51 pm ---4) I am thinking that having separate commands for each action is worth while now. It seems nice to have separate commands so the plugin can have one big case statement only and the JukePlugin class module can be less involved. Basically we use the "Juke_PluginCommand()" routine for everything and simply standard the cmdName and cmdValue string values which can be passed as parameters.
--- End quote ---
Again, a few extra functions are ok. Most is done in Juke_Command() anyway. The JukePlugin class module is already VERY basic anyway. Let's just accept these other functions please, as debating these minor points only holds up any more progress. (It's starting to sound like commands.txt all over again lol)
unclet:
--- Quote ---If you want to be able to receive data from the plugin at any time create a timer and put in a special command that is sent over every 2 seconds to check for data
Eg. Juke_Command("JUKE_DATA_CHECK_TIMER", "STATUS")
Then you can check for data from the plugin and the plugin can send it over whenever it wants to. But I don't really see a need for such a thing, do you?
--- End quote ---
I believe Space Fractal wants to be able to implement a remote control for his jukebox so he can press a button and have the jukebox do stuff. I guess I thought his remote control interface would need to go through some plugin interface and then to the jukebox. If so, then the plugin would need to send messages to the jukebox at anytime. Perhaps I am wrong?
--- Quote ---Because it's just standard programming practice to do it that way.
--- End quote ---
If those are standard plugin functions I can live with them ... no problem. I like how most all commands
--- Quote ---Again, a few extra functions are ok. Most is done in Juke_Command() anyway. The JukePlugin class module is already VERY basic anyway.
--- End quote ---
Yes, I wrote those questions before checking out your slimmed down JukePlugin class module. Lets get on with defining the cmdName and cmdValue strings now.
loadman:
--- Quote from: headkaze on January 08, 2008, 05:34:32 pm ---Yay! It works :)
Here is the dll code
--- Code: ---JUKEPLUGIN_API PCHAR __stdcall Juke_GetPluginInfo(int Value)
{
sprintf(m_buffer, "%s,%s,%s", PLUGIN_NAME, PLUGIN_AUTHOR, PLUGIN_VERSION);
return m_buffer;
}
--- End code ---
And here is the code to get the info back...
--- Code: ---Dim sPluginInfo As String
Dim sArray() As String
sPluginInfo = PtrToVBString(CallFuncPtr(pDC, pGetPluginInfo, vbNull))
sArray = Split(sPluginInfo, ",")
If UBound(sArray) + 1 = 3 Then
PluginInfo.Name = sArray(0)
PluginInfo.Author = sArray(1)
PluginInfo.Version = sArray(2)
End If
--- End code ---
Attached is the complete code
--- End quote ---
:cheers: :applaud: :cheers: :applaud: :cheers: :applaud: :cheers: :applaud: :cheers: :applaud:
I even got it a Dll made in Delphi to send the data back to the VB6 test app
:notworthy: :notworthy: :notworthy: :notworthy: :notworthy: :notworthy: :notworthy: :notworthy:
--- Code: ---library JukePlugin;
uses
Dialogs;
{*****************************************************************************}
var
PLUGIN_NAME : pChar = 'LCD Display';
PLUGIN_AUTHOR : pChar = 'Loadman';
PLUGIN_VERSION : pChar = 'Beta A';
{*****************************************************************************}
function Juke_GetPluginInfo(A:integer):Pchar ; stdcall;
begin
result := PChar(PLUGIN_NAME+','+ PLUGIN_AUTHOR+','+PLUGIN_VERSION);
end;
{*****************************************************************************}
procedure Juke_SongStart(A: Integer); stdcall;
begin
Showmessage('DLL has recieved Juke_SongStart message');
end;
{*****************************************************************************}
procedure Juke_Shutdown(A: Integer); stdcall;
begin
Showmessage('DLL has recieved Juke_Shutdown message');
end;
{*****************************************************************************}
exports
Juke_GetPluginInfo,
Juke_SongStart,
Juke_Shutdown;
{$R *.res}
begin
end.
--- End code ---
unclet:
headkaze
Your latest code has a problem in my software. When the Form_Unload() routine is called, my project crashes when the ShutDown routine is being called. If I go into the JukePlugin class module and comment out the call to CallFuncPtr for the ShutDown call, then my project no longer crashes.
headkaze:
--- Quote from: unclet on January 08, 2008, 08:54:00 pm ---I believe Space Fractal wants to be able to implement a remote control for his jukebox so he can press a button and have the jukebox do stuff. I guess I thought his remote control interface would need to go through some plugin interface and then to the jukebox. If so, then the plugin would need to send messages to the jukebox at anytime. Perhaps I am wrong?
--- End quote ---
No, this is a great idea! In fact I have some C++ source code for recieving messages from an MCE Remote. Although come to think of it most buttons on that remote are read as keyboard input so it would work without a plugin anyway. But I like the concept and it's certainly easy to implement using the current plugin design.
Since this is input you would need to send a command, say, every 200 milliseconds to check for input. That's so you when you press a button there is no delay from the Jukebox to process it.
Eg.
--- Code: ---Plug_Command("JUKE_READ_INPUT", "MCE_REMOTE");
--- End code ---
Something like that that is called every 200 milliseconds in a timer. The thing is now Juke_Command() has two way communication you can do anything you like with it. All you have to do is set up a timer if you need to constantly check for data from the plugin. In most cases though a timer would not be necessary.
--- Quote from: unclet on January 08, 2008, 08:54:00 pm ---If those are standard plugin functions I can live with them ... no problem. I like how most all commands
--- End quote ---
:applaud:
--- Quote from: unclet on January 08, 2008, 08:54:00 pm ---Yes, I wrote those questions before checking out your slimmed down JukePlugin class module. Lets get on with defining the cmdName and cmdValue strings now
--- End quote ---
:cheers:
--- Quote from: loadman on January 08, 2008, 09:03:55 pm ---I even got it a Dll made in Delphi to send the data back to the VB6 test app
--- End quote ---
Sweet! :)
--- Quote from: unclet on January 08, 2008, 09:09:53 pm ---Your latest code has a problem in my software. When the Form_Unload() routine is called, my project crashes when the ShutDown routine is being called. If I go into the JukePlugin class module and comment out the call to CallFuncPtr for the ShutDown call, then my project no longer crashes.
--- End quote ---
Okay I did add some extra code to check for these sort of problems. The follow code will make sure after shutting down no call to the library can be made again.
--- Code: ---Public Function Shutdown() As Long
Dim RetVal As Long
If pShutdown <> 0 Then
RetVal = CallFuncPtr(pDC, pShutdown, vbNull)
End If
FreeLibrary hDll
pGetPluginInfo = 0
pInitialize = 0
pShutdown = 0
pCommand = 0
Shutdown = RetVal
End Function
--- End code ---
Try the new one attached.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version