1***@qq.com
1***@qq.com
  • 发布:2016-11-13 21:36
  • 更新:2016-11-24 10:36
  • 阅读:1125

关于native.js访问安卓系统多媒体数据库

分类:Native.js
想通过安卓系统多媒体数据库,来进行本地音乐的扫描。  
            ```javascript  

<script type="text/javascript">
var songsong=null,songsinger=null,songpath=null,songduration=null,songsize=null;
document.addEventListener("plusready",function(){
var Context=plus.android.importClass("android.content.Context");
var Cursor=plus.android.importClass("android.database.Cursor");
var MediaStore=plus.android.importClass("android.provider.MediaStore");
// var context=new Context();
var cursor=new Cursor();
cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null,
null, MediaStore.Audio.AudioColumns.IS_MUSIC);
if(cursor!=null){
while(cursor.moveToNext()){
songsong = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DISPLAY_NAME));
songsinger = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
songpath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
songduration = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
songsize = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
var li=null;
li=document.createElement("li");
li.innerText=songsong+" "+songsinger+" "+songpath+" "+songduration+" "+songsize;
li.className="mui-table-view-cell li";
document.getElementById("ul").appendChild(li);
}
}
},false);
</script>


   这是根据Java代码改编的,请问各位大神这样context.getContentResolver()中,context在这里应该怎么换成什么啊?
2016-11-13 21:36 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

不知道你解决了扫描的问题没有,我这一直有TypeError的错误。

该问题目前已经被锁定, 无法添加新回复