简体   繁体   中英

How to mute skype via the skype4com api using C#

I'm just messing around with the skype4com api in c# and I'm a bit confused on how to mute skype with the api. I get an error on the line "skype.Mute = true;"

error:

Error   1   Ambiguity between 'SKYPE4COMLib.ISkype.Mute' and   'SKYPE4COMLib._ISkypeEvents_Event.Mute'  C:\Users\derp\documents\visual studio   2010\Projects\SkypeBot\SkypeBot\Form1.cs    33  39  SkypeBot

code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SKYPE4COMLib;

namespace SkypeBot
{
public partial class Form1 : Form
{            
    public Skype skype = new Skype();
    public bool afk;
    public Form1()
    {
        InitializeComponent();
        ((_ISkypeEvents_Event)skype).MessageStatus += OnMessageStatus;
        skype.Attach(8);
    }
    void OnMessageStatus(ChatMessage msg, TChatMessageStatus status)
    {
            if (status.ToString() == "cmsSending" && msg.Sender.DisplayName == skype.CurrentUser.DisplayName)
            {
                if (msg.Body == "!afk")
                {
                        afk = !afk;
                        if (afk)
                        {
                            msg.Body = msg.Sender.FullName + " is now afk!";

the following line is the issue:

                            skype.Mute = true;
                        }
                        else
                        {
                            msg.Body = msg.Sender.FullName + " has returned!";
                        }
            }
        }
    }
}
}

I do not have the Skype API at hand, but it seems that the Skype class implements two interfaces that support a Mute property.

Try casting the reference to a specific interface, and then calling the method, like:

((ISkype)skype).Mute = true;

or

((_ISkypeEvents_Event)skype).Mute = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM