The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Read EPG from Mediacenter by API

Last post 06-18-2008, 12:16 AM by AndyC. 15 replies.
Page 1 of 2 (16 items)   1 2 Next >
Sort Posts: Previous Next
  •  09-22-2006, 1:23 PM 559

    Read EPG from Mediacenter by API

    Hello!

    Is there  a way to read the EPG "Electronic program Gyde" from mediacenter by API?

    I was searching in the documentation, but a did nun found anything. the only thing i found is TV Schedul.foundProgram or findService. But bouth of them are not really the EPG of the TV part of mediacenter.

    can anybody help?

     

  •  09-22-2006, 10:21 PM 561 in reply to 559

    Re: Read EPG from Mediacenter by API

    The Windows Media Center API does not include methods for accessing the EPG. FindProgram and FindService are there to help you tune to live TV shows and the Click To Record API helps you schedule recordings.
    Charlie Owen (Microsoft)
  •  09-23-2006, 1:23 AM 562 in reply to 559

    Re: Read EPG from Mediacenter by API

    Hi Jonathan,

    there is no official API for this but you can access the EPG database using ehepg.dll. The EPG database is a file-based SQLLite database.

    In your project add a reference to %windir%\ehepg.dll and checkout the namespace:

    Microsoft.Ehome.Epg.Database

    You can create a SQLLiteConnection and access the tables (programs, services, lineups, ect...). It's a pretty easy database.

  •  09-24-2006, 10:14 AM 563 in reply to 562

    Re: Read EPG from Mediacenter by API

    HI!

    Thaks for the fast answer!

    But i have problems to write sql statements in the SQLLite Database.

    For example: how do i transfer "select * from tabelle" in the database to make this statement work?
    i tryed many things, but i think i am on a wrong way... 

     

  •  09-25-2006, 4:24 AM 566 in reply to 563

    Re: Read EPG from Mediacenter by API

    Hi,

    I am at work right now - I will post a little code snippet when I am back at home.

     

  •  09-25-2006, 9:09 AM 567 in reply to 566

    Re: Read EPG from Mediacenter by API

    Here you go:

    1. Add a reference to ehepg.dll

    2. Use the following code:

    DataSet ds = new DataSet();
    SqlLiteConnection conn = new SqlLiteConnection();
    conn.Init(
    EpgFileHelper.CurrentEpgFile, true);
    conn.Open();

    SqlLiteCommand scmd = (SqlLiteCommand)conn.CreateCommand();
    scmd.CommandText =
    "select servicename, callsign from services order by servicename asc";
    scmd.CommandType =
    CommandType.Text;
    SqlLiteDataAdapter adapter = new SqlLiteDataAdapter();
    adapter.SelectCommand = scmd;

    adapter.Fill(ds);
    conn.Close();
    String strCallsigns = String.Empty;

    foreach (DataRow row in ds.Tables[0].Rows)
          
    if(row[0].ToString().Trim() != String.Empty)
                strCallsigns +=
    "Servicename: " + row[0].ToString() + " (" +
                      row[1].ToString() +
    ")\n";

    MessageBox.Show(strCallsigns);


    This will show all services + callsign in a simple message box. You can get a list off all tables with the following SQL satement:

    select * from information_schema.tables

    Have fun

  •  10-19-2006, 1:36 AM 789 in reply to 567

    Re: Read EPG from Mediacenter by API

    Hi,

     

    I've made the same code for vb.net :

    Dim conn As New Microsoft.Ehome.Epg.Database.SqlLiteConnection

    Dim sqlcom As New Microsoft.Ehome.Epg.Database.SqlLiteCommand

    Dim sqladap As New Microsoft.Ehome.Epg.Database.SqlLiteDataAdapter

    Dim ds As New DataSet

    Dim strCallsigns As String

    Dim geteld, i As Integer

    On Error Resume Next

    conn.Init(Microsoft.Ehome.Epg.Helper.EpgFileHelper.CurrentEpgFile, True)

    conn.Open()

    sqlcom = conn.CreateCommand()

    sqlcom.CommandText = "select servicename, callsign from services order by servicename asc"

    sqlcom.CommandType = CommandType.Text

    sqladap.SelectCommand = sqlcom

    sqladap.Fill(ds)

    conn.Close()

    geteld = ds.Tables(0).Rows.Count

    With ds.Tables(0)

    For i = 0 To geteld - 1

    If .Rows(i).ToString().Trim() = "" Then

    strCallsigns += "Servicename: " + .Rows(i).ToString() + " (" + .Rows(i).ToString() & ")\n"

    End If

    Next i

    End With

    MessageBox.Show(strCallsigns)

     

     

    This is the error that i've got:

    An unhandled exception of type 'System.Security.SecurityException' occurred in system.windows.forms.dll

    Additional information: Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

    Anybody can help?

     

    Thank you

     

     

  •  10-19-2006, 4:13 PM 796 in reply to 789

    Re: Read EPG from Mediacenter by API

    Most likely:

    1) You need to run hosted in MCE 

    2) Set your XBAP to run in Full Trust.

    Jossef


    Jossef
  •  10-23-2006, 5:41 AM 829 in reply to 796

    Re: Read EPG from Mediacenter by API

    It's a windowsapplication, no xbap!

    I've installed visual studio 2005, and i don't get that fault anymore.

    When I run I have no build errors but the output is empty.

    I think there's something with the sqliteconnection (sqldb20.dll).

    I can't make a reffernce to it. So i'm stuck. Can anybody help!

    I can send the souorce by mail!

     

     

     

     

     

     

     

     

  •  06-12-2007, 1:34 PM 3563 in reply to 829

    Re: Read EPG from Mediacenter by API

    Did you try copy the files from %windir%\ehome to your application folder?
  •  06-13-2007, 8:08 PM 3589 in reply to 829

    Re: Read EPG from Mediacenter by API

    Cage007:

    It's a windowsapplication, no xbap!

    I've installed visual studio 2005, and i don't get that fault anymore.

    When I run I have no build errors but the output is empty.

    I think there's something with the sqliteconnection (sqldb20.dll).

    I can't make a reffernce to it. So i'm stuck. Can anybody help!

    I can send the souorce by mail!

     

    When select the output in VS2005 to be "release", your dll (output) will be located in different folder(bin/Release). 

    You may double check it.



  •  07-28-2007, 7:26 AM 4039 in reply to 3589

    Re: Read EPG from Mediacenter by API

    Hi,

    I`m working on the same Problem wirth an xpMCE 2005 AddIn. And I bacome the same Error Report:

    System.Security.SecurityException: Anforderung des Berechtigungstyps System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ist fehlgeschlagen.
       at tvbAddIn.MSXPMCE2005.Common.EPG.test()
       at tvbAddIn.MSXPMCE2005.tvbBackgroundAddIn.startApplication()
       at tvbAddIn.MSXPMCE2005.tvbBackgroundAddIn.hook_KeyDown(Object sender, Keys keyCode, Boolean shift)
       at tvbAddIn.MSXPMCE2005.Common.KeyboardHook.HookCallback(Int32 nCode, IntPtr wParam, IntPtr lParam)

    Status der fehlgeschlagenen Berechtigung:
    <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                 version="1"
                 PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9"/>

    The AddIn is developed with VS 2003.

     

    Thanks for Help.

  •  10-20-2007, 3:41 PM 5276 in reply to 567

    Re: Read EPG from Mediacenter by API

    I have attempted to compile the program above but i have not been able to find the assembly that 

    EpgFileHelper.CurrentEpgFile

    is contained in could you please help me find the EpgFile for Media Center also how would i explore the Schema of the file?

  •  10-21-2007, 2:27 PM 5285 in reply to 5276

    Re: Read EPG from Mediacenter by API

    there is a simple WinForms sample here that i've tested on MCE Vista :

    http://www.mperfect.net/umpcFrame/GuideSimple.zip

    it uses a typed dataset for table relationships.

    casey

  •  06-17-2008, 11:21 AM 7695 in reply to 5276

    Re: Read EPG from Mediacenter by API

    It seems that EpgFileHelper used to be in Microsoft.Ehome.Epg.Helper, in ehepg.dll

    However, it no longer seems to be there.  This is what's used in GuideSimple to get the filename for the current EPG.

            public static String GetCurrentEpgFile()
            {
                String strEpgFolder = Environment.GetEnvironmentVariable( "PROGRAMDATA" ) + "\\Microsoft\\eHome\\EPG";
                String[] strFiles = Directory.GetFiles( strEpgFolder, "*.sdf" );
                String strFile = ( strFiles.Length > 0 ? strFiles[ 0 ] : String.Empty );

                foreach( String s in strFiles )
                {
                    if( File.GetCreationTime( s ) > File.GetCreationTime( strFile ) )
                        strFile = s;
                }
                return strFile;
            }

    Hope that helps.
Page 1 of 2 (16 items)   1 2 Next >
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems