Page tree


 Recently Updated

 Latest Releases

 MediaPortal 1.18 Final
            Releasenews | Download
 MediaPortal 2.1.3 Final 
            Releasenews | Download

The purpose of this example is to demonstrate :

  1. how to connect to the TV-Server
  2. how to retrieve the state of each TV card

The code can be found in the tv server SVN under doc\examples\examples\example1

#region Copyright (C) 2005-2010 Team MediaPortal

// Copyright (C) 2005-2010 Team MediaPortal
// MediaPortal is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
// MediaPortal is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with MediaPortal. If not, see <>.


using System;
using System.Collections.Generic;
using System.Text;
using TvControl;          // include the tvserver remote control interfaces
using TvLibrary.Channels; // include tv-channel types

namespace Example1
  /// <summary>
  /// Example which connects to a tv-server
  /// and shows the status for each tv-card
  /// </summary>
  class Program
    static void ShowCardStatus(int cardIndex)
      Console.WriteLine("card:{0}", cardIndex);
      int cardId=RemoteControl.Instance.CardId(cardIndex);
      User user = new User();
      user.CardId = cardId;
      VirtualCard card = new VirtualCard(user, RemoteControl.HostName);
      Console.WriteLine("  Type          :{0}", card.Type);
      Console.WriteLine("  Name          :{0}", card.Name);
      Console.WriteLine("  Device        :{0}", card.Device);
      Console.WriteLine("  IsTimeShifting:{0} {1}", card.IsTimeShifting,card.TimeShiftFileName);
      Console.WriteLine("  IsRecording   :{0} {1}", card.IsRecording,card.RecordingFileName);
      Console.WriteLine("  IsScanning    :{0}", card.IsScanning);
      Console.WriteLine("  IsGrabbingEpg :{0}", card.IsGrabbingEpg);
      Console.WriteLine("  IsScrambled   :{0}", card.IsScrambled);
      Console.WriteLine("  ChannelName   :{0}", card.ChannelName);
      Console.WriteLine("  Channel       :{0}", card.Channel);
      Console.WriteLine("  SignalQuality :{0}", card.SignalQuality);
      Console.WriteLine("  SignalLevel   :{0}", card.SignalLevel);
      Console.WriteLine("  IsTunerLocked :{0}", card.IsTunerLocked);
      bool isLocked = card.IsLocked(out user);
      if (isLocked)
        Console.WriteLine("  IsLocked by   :{0}", user.Name);
    static void Main(string[] args)
      //set the hostname of the tvserver
      RemoteControl.HostName = "localhost";

      //Enumerate all cards installed on the tvserver
      int cardCount = RemoteControl.Instance.Cards;
      for (int i = 0; i < cardCount; ++i)




This page has no comments.