找回密码
 立即注册
查看: 2402|回复: 0

Tizen设备创建一个播放列表

[复制链接]
发表于 2015-9-17 22:15:16 | 显示全部楼层 |阅读模式
得到所有音频项目并创建一个播放列表。
  1. var audio = document.getElementById("audio");

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

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

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

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

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

  18.     for (var i=0; i < contents.length; i++) {
  19.         console.log(i + ":" + contents[i].type + ":" + contents[i].title + ":" +contents[i].mimeType);
  20.         console.log("album:" + contents[i].album);
  21.         console.log("artists:" + contents[i].artists[0]);
  22.         console.log("duration:" + contents[i].duration);
  23.         console.log("Item bitrate: " + contents[i].bitrate);
  24.         console.log("Item trackNumber: " + contents[i].trackNumber);
  25.         console.log("Item size: " + contents[i].size);

  26.         var listItem = document.createElement("li");
  27.         listItem.innerHTML = contents[i].title;
  28.         listItem.contentURL = contents[i].contentURI;
  29.         listItem.onclick = onclickFunction;

  30.         itemsList.appendChild(listItem);
  31.     }
  32. }


  33. // Requires the following Tizen Privilege:
  34. // <tizen:privilege name="http://tizen.org/privilege/content.read"/>
  35. // Add this line to config.xml file
复制代码
欢迎来到泰泽网:http://www.tizennet.com/ 泰泽论坛:http://bbs.tizennet.com/ 好没有内涵哦,快到设置中更改这个无聊的签名吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|泰泽应用|泰泽论坛|泰泽网|小黑屋|Archiver|手机版|泰泽邮箱|泰泽网 ( 蜀ICP备13024062号-1 )

GMT+8, 2024-4-19 09:51 , Processed in 0.062382 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表