Jump to content



Photo

C#, C++ help to catch filename


  • Please log in to reply
4 replies to this topic

#1 Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 20 November 2012 - 10:14

I have couple of years of experience with C# and C++, making database programs and so on but I would need to make a simple DLL for use in Windows Media Center and I got no clue on how to do some things I would need. Sorry english is not my native language so i need to explain this the long way.

I would need to know what happens when I click play on Windows Media Center movie library (Blu-ray or MKV). When I click play WMC loads the DLL but the problem is how to make the DLL catch the information from WMC when clicked play, like the filename of the file.

For example Total Media Theatre has a WMC plugin, a registry key that tells WMC to load TMT WMC plugin DLL when trying to play BD and the DLL catches the filename and launches the file in TMT on top of WMC.

Here's all I could find about this, it has everything except no info about the DLL part, how to pass the filename to external player.

http://msdn.microsof...p/bb189523.aspx

With the samples above WMC opens the external player by sendiong it it command for example "C:\player.exe" the dll would need to send the command "C:\player.exe G:\" for example.


#2 OP Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 20 November 2012 - 11:01

On TMT it works like this. On registry, instead of directly to player they specify a .HTM file (along with the htm they have playerloader.dll):

<html>
<head>
<title>TotalMedia Theatre</title>
<script>
function GetArgument(ji)
{
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++)
    {
	    ft = gy[i].split("=");
	    if (ft[0] == ji) { return ft[1]; }
    }
    return null;
}
function GetPlayerCommandLine()
{
    var path = null;
    var filePath = null;
    try
    {
	    path = GetArgument("uri");
	    if (path == null) path = window.external.MediaCenter.MediaContext.GetProperty("Name");
    }  
    catch (e) { path = window.location.search.substring(1); }

    var i = path.indexOf("///");
    if(i == -1) i = path.indexOf("//");
    else i = i + 3;
    filePath = path.substring(i);
    if (path.indexOf("dvd") != -1 && filePath.length <= 3) {
	    var tempString;
	    if (filePath.charAt(2) == '/') tempString = filePath.substring(0, 2);
	    filePath = tempString + "\\";
    }
    return filePath;
}
function IsMCEEnabled()
{
return true;
}
function ReEnterDirectXExclusiveMode()
{
return false;
}
function OnLoad()
{
    var dxExclusive = false;

    try
    {
	    window.external.MediaCenter.DirectXExclusive = false;
	    dxExclusive = window.external.MediaCenter.DirectXExclusive;
    }
    catch (e) { LaunchPlayer(); }
    if (dxExclusive == true) setTimeout(OnLoad, 100);
    else { LaunchPlayer(); }
}
function OnUnload()
{
    try { PlayerLoader4.UnloadPlayer(); }
    catch (e) { }
}
function GoBack()
{
    PlayerLoader4.UnloadPlayer();		  
    try { window.external.MediaCenter.CloseApplication(); }
    catch (e) { }
}
function LaunchPlayer()
{
    try
    {
	    var comActiveX = new ActiveXObject("PlayerLoader4.PlayerLoader4Ctrl.32");
	    delete comActiveX;
	    document.body.innerHTML = '<object id="PlayerLoader4" width="100%" height="100%" classid="clsid:b1e62c80-95a6-49c1-8806-b43e6a4f3742"></object>';
    }
    catch (e)
    {
	    document.body.innerHTML = '<object id="PlayerLoader4" width="100%" height="100%" classid="clsid:7ae2296c-ad65-4dbc-9413-96c5853418a7"></object>';
    }
    var filePath = GetPlayerCommandLine();
    try { PlayerLoader4.GetCmdLine(GetPlayerCommandLine()); }
    catch (e) { }
    PlayerLoader4.LoadPlayer();
}

</script>
<style type="text/css">
* { margin: 0px; padding: 0px; }
</style>
</head>
<body bgcolor="#004080" onload="OnLoad();" onunload="OnUnload();" scroll="no">
</body>
</html>



#3 OP Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 20 November 2012 - 14:33

Would it be possible to use only the htm to launch external player and catch the filename?

Hmm, no.

http://blogs.msdn.co...dia-center.aspx

#4 OP Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 20 November 2012 - 15:33

So I would need to do a wrapper exe that executes the player.exe so it will be launched with filepath. Maybe using the ExternalProcess but how to get the filepath from WMC?

#5 OP Joni_78

Joni_78

    Neowinian Senior

  • Joined: 19-April 04
  • Location: Finland
  • OS: Windows 8 Pro with Media Center
  • Phone: Nokia Lumia 920

Posted 20 November 2012 - 20:53

How does this work? I think this starts something from the .dll file which then loads the player exe. b1e62c80-95a6-49c1-8806-b43e6a4f3742 below is the dll file, dunno what 7ae2296c-ad65-4dbc-9413-96c5853418a7 is as there was no occurences on the registry. I don't understand how this starts anything from the dll.

function LaunchPlayer()
{
    try
    {
	    var comActiveX = new ActiveXObject("PlayerLoader4.PlayerLoader4Ctrl.32");
	    delete comActiveX;
	    document.body.innerHTML = '<object id="PlayerLoader4" width="100%" height="100%" classid="clsid:b1e62c80-95a6-49c1-8806-b43e6a4f3742"></object>';
    }
    catch (e)
    {
	    document.body.innerHTML = '<object id="PlayerLoader4" width="100%" height="100%" classid="clsid:7ae2296c-ad65-4dbc-9413-96c5853418a7"></object>';
    }
    var filePath = GetPlayerCommandLine();
    try { PlayerLoader4.GetCmdLine(GetPlayerCommandLine()); }
    catch (e) { }
    PlayerLoader4.LoadPlayer();
}




Click here to login or here to register to remove this ad, it's free!