流星悟语 发表于 2015-9-17 22:15:16

Tizen设备创建一个播放列表

得到所有音频项目并创建一个播放列表。
var audio = document.getElementById("audio");

// Retrieve the ContentManager interface instance using the tizen global object
var manager = tizen.content;

// Retrieving the Audio list.
var contentType = "AUDIO";
var filter = new tizen.AttributeFilter("type", "EXACTLY", contentType);
manager.find(mediaItemArray, onError, null, filter);

function onError(response) {
    console.log( "The following error occurred: " + response.name);
}

var onclickFunction = function() {
      alert("clicked" + this.innerHTML);
      audio.src = this.contentURL;
};

function mediaItemArray (contents) {
    var itemsList = document.getElementById('playlist');
    console.log("Successfully retrieved the list of Audio items");

    for (var i=0; i < contents.length; i++) {
      console.log(i + ":" + contents.type + ":" + contents.title + ":" +contents.mimeType);
      console.log("album:" + contents.album);
      console.log("artists:" + contents.artists);
      console.log("duration:" + contents.duration);
      console.log("Item bitrate: " + contents.bitrate);
      console.log("Item trackNumber: " + contents.trackNumber);
      console.log("Item size: " + contents.size);

      var listItem = document.createElement("li");
      listItem.innerHTML = contents.title;
      listItem.contentURL = contents.contentURI;
      listItem.onclick = onclickFunction;

      itemsList.appendChild(listItem);
    }
}


// Requires the following Tizen Privilege:
// <tizen:privilege name="http://tizen.org/privilege/content.read"/>
// Add this line to config.xml file
页: [1]
查看完整版本: Tizen设备创建一个播放列表