Sidebar Menu

GetSoundFileLength

This method retrieves a sound file's length in seconds.

Syntax

GetSoundFileLength(SoundFileID, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
SoundFileID

The sound file's ID.

String True greeting
LicenseKey

Your license key.

String True 00000000-0000-0000-0000-000000000000

Response

Returns: Double

Description: The length of the file, in seconds.

Sample:
6.123

Code Samples

You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.

/* https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl was added as a Service Reference and given the name WSDL */

using WSDL;

var client = new PhoneNotifySoapClient(PhoneNotifySoapClient.EndpointConfiguration.PhoneNotifySoap);
var soundFileId = "greeting";
var length = await client.GetSoundFileLengthAsync(soundFileId, YOUR_LICENSE_KEY);

Console.WriteLine("Sound file length: " + length);
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public final class GetSoundFileLength {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://ws.esendex.us/NotifyWS/PhoneNotify.asmx/GetSoundFileLength?"
                            + "SoundFileID=test sound file"
                            + "&LicenseKey=00000000-0000-0000-0000-000000000000");
            try {
                InputStream in = url.openStream();
                StreamSource source = new StreamSource(in);
                printResult(source);
            } catch (java.io.IOException e) {
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    private static void printResult(Source source) {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            StreamResult sr = new StreamResult(bos);
            Transformer trans = TransformerFactory.newInstance().newTransformer();
            Properties oprops = new Properties();
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperties(oprops);
            trans.transform(source, sr);
            System.out.println("**** Response ******");
            System.out.println(bos.toString());

            bos.close();
            System.out.println();
        } catch (Exception e) {
        }
    }
}
import zeep

client = zeep.Client(wsdl="https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl")
sound_file_id = "greeting"
license_key = "00000000-0000-0000-0000-000000000000"

response = client.service.GetSoundFileLength(sound_file_id, license_key)

print(response)
GET /NotifyWS/PhoneNotify.asmx/GetSoundFileLength?SoundFileID=string&LicenseKey=string HTTP/1.1
Host: ws.esendex.us
POST /NotifyWS/PhoneNotify.asmx/GetSoundFileLength HTTP/1.1
Host: ws.esendex.us
Content-Type: application/x-www-form-urlencoded
Content-Length: length

SoundFileID=string&LicenseKey=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<double xmlns="https://ws.esendex.us/NotifyWS/">double</double>
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://ws.esendex.us/NotifyWS/GetSoundFileLength"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSoundFileLength xmlns="https://ws.esendex.us/NotifyWS/">
      <SoundFileID>string</SoundFileID>
      <LicenseKey>string</LicenseKey>
    </GetSoundFileLength>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetSoundFileLengthResponse xmlns="https://ws.esendex.us/NotifyWS/">
      <GetSoundFileLengthResult>double</GetSoundFileLengthResult>
    </GetSoundFileLengthResponse>
  </soap:Body>
</soap:Envelope>
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetSoundFileLength xmlns="https://ws.esendex.us/NotifyWS/">
      <SoundFileID>string</SoundFileID>
      <LicenseKey>string</LicenseKey>
    </GetSoundFileLength>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetSoundFileLengthResponse xmlns="https://ws.esendex.us/NotifyWS/">
      <GetSoundFileLengthResult>double</GetSoundFileLengthResult>
    </GetSoundFileLengthResponse>
  </soap12:Body>
</soap12:Envelope>