~ories/+junk/digitalsign

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtMultimedia 5.0


ApplicationWindow {
    id: window
    visible: true
    visibility: "FullScreen"


    MediaPlayer {
        id: mediaplayer
    }

    Image {
        id: pic1
        visible: true
    }
    Image {
        id: pic2
        visible: true
        opacity: 0
        anchors.fill: pic1
    }

    Timer {
        id: showTimer
        onTriggered: show()
        repeat: false
    }

    ListModel {
        id: objectlist
    }

    Component.onCompleted: getData();

    property int m_position: 0
    property bool m_loop: true

    function show(){

        if(m_loop){
            if(m_position >= objectlist.count ){
                m_position = 0;
                console.log("here")
            }
        }
        else{
            if(m_position >= objectlist.count ){
                Qt.quit()
            }
        }

        pic1.source = objectlist.get(m_position).url;
        showTimer.interval = objectlist.get(m_position).duration;

        console.log(showTimer.interval)

        m_position++;

        showTimer.start();

    }    

    function getData() {
        var xmlhttp = new XMLHttpRequest();

        var url = "file:///tmp/album.json";

        xmlhttp.open("GET", url);
        xmlhttp.send();

        xmlhttp.onreadystatechange=function() {
            if (xmlhttp.readyState == 4) {
                parseResponse(xmlhttp.responseText);
            }
            else{
                console.log(xmlhttp.responseText)
            }
        }

    }

    function parseResponse(response) {
        var arr = JSON.parse(response);
        var f = arr["objects"];

        m_loop = arr["loop"];

        for(var i = 0; i < f.length; i++) {
            objectlist.append( { "url": f[i].url, "duration":f[i].duration })
        }
        console.log(objectlist.count)
        show();
    }

}