Connecting to the internet using Concept N

52 Views Asked by At

I can’t connect to the internet using Concept N. I am using jquery with a simple $.get, but it is just not working. Can someone help me with this?

1

There are 1 best solutions below

0
On

You actually need to use the da.getXHr() function to access external web services. Here is an example of how to access rss data using jquery. First thing to do is download jquery and include it in your index.html file:

    <script type="text/javascript" src="app/jquery.min.js"></script>

Now use this code snippet to access a rss url with jquery. Be sure to replace the line "** Enter-rss-2.0-url-here **" with your own rss url

/*
 * Copyright 2016 Sony Corporation
 */
var title;
var description;
/**
 * The callback to prepare a segment for play.
 * @param  {string} trigger The trigger type of a segment.
 * @param  {object} args    The input arguments.
 */
da.segment.onpreprocess = function (trigger, args) {
    console.log('onpreprocess', { trigger: trigger, args: args });
    //da.startSegment(null, null);
    $.ajax({
        url:"** Enter-rss-2.0-url-here **",
        type: "GET",
        dataType: 'xml',
        xhr: function () { return da.getXhr(); },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log('ajax error jqXHR.status[' + jqXHR.status + ']');
            def.reject("failed with error "+jqXHR.status);
            return;
        },
        success: function (data, textStatus, jqXHR) {
            $(data).find("item:first").each(function() {
                title = $(this).find("title").text();
                description = $(this).find("description").text()
            })
            da.startSegment(null, null)
        }
    })
};

/**
 * The callback to start a segment.
 * @param  {string} trigger The trigger type of a segment.
 * @param  {object} args    The input arguments.
 */
da.segment.onstart = function (trigger, args) {
    console.log('onstart', { trigger: trigger, args: args });
    var synthesis = da.SpeechSynthesis.getInstance();
    synthesis.speak("Title "+title+", Content "+description, {
        onstart: function () {
            console.log('speak start');
        },
        onend: function () {
            console.log('speak onend');
            da.stopSegment();
        },
        onerror: function (error) {
            console.log('speak cancel: ' + error.messsage);
            da.stopSegment();
        }
    });
};