AcoustID.Web.LookupService.GetAsync C# (CSharp) Метод

GetAsync() публичный Метод

Lookup a fingerprint using the AcoustID webservice.
public GetAsync ( string fingerprint, int duration, string meta ) : Task
fingerprint string The audio fingerprint.
duration int The total duration of the audio.
meta string Request meta information.
Результат Task
        public async Task<LookupResponse> GetAsync(string fingerprint, int duration, string[] meta)
        {
            try
            {
                using (var body = BuildRequestBody(fingerprint, duration, meta))
                {
                    // If the request contains invalid parameters, the server will return
                    // "400 Bad Request" and we'll end up in the first catch block.
                    string response = await WebHelper.SendPost(URL, body, UseCompression);

                    return parser.ParseLookupResponse(response);
                }
            }
            catch (WebException e)
            {
                // Handle bad requests gracefully.
                return CreateErrorResponse(e.Response as HttpWebResponse);
            }
            catch (Exception e)
            {
                throw e;
            }
        }

Same methods

LookupService::GetAsync ( string fingerprint, int duration ) : Task

Usage Example

Пример #1
0
        private void Lookup(string fingerprint, int duration)
        {

            btnFingerprint.IsEnabled = false;

            LookupService service = new LookupService();

            service.GetAsync((results, e) =>
            {
                btnOpen.IsEnabled = true;

                if (e != null)
                {
                    System.Windows.MessageBox.Show(e.Message, "Webservice error");
                    return;
                }

                if (results.Count == 0)
                {
                    if (String.IsNullOrEmpty(service.Error))
                    {
                        System.Windows.MessageBox.Show("No results for given fingerprint.");
                    }
                    else System.Windows.MessageBox.Show(service.Error, "Webservice error");

                    return;
                }

                foreach (var result in results)
                {
                    var li = new AcoustIdItem();
                    li.AcoustId = result.Id;
                    li.Score = result.Score.ToString();
                    li.Recordings = result.Recordings;

                    lvResults.Items.Add(li);

                }
            }, fingerprint, duration, new string[] { "recordings", "compress" });
        }
All Usage Examples Of AcoustID.Web.LookupService::GetAsync