private Cursor getQueryCursor(AsyncQueryHandler async, String filter) { if (filter == null) { filter = ""; } Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter)); Cursor ret = null; if (async != null) { async.startQuery(0, null, search, mCursorCols, null, null, null); } else { ret = MusicUtils.query(this, search, mCursorCols, null, null, null); } if (ret != null) { MusicLogUtils.e(TAG, " ret != null getQueryCursor: Count=" + ret.getCount() + " search=" + filter); /// M: when cursor's count be 0;means no matches media files,so show // empty view,otherwise show seached listview. @{ int what = (ret.getCount() == 0) ? EMPTY_SHOW : LIST_SHOW; mReScanHandler.sendMessage(mReScanHandler.obtainMessage(what)); /// @} } return ret; }
时间: 2023-05-22 10:05:44 浏览: 95
这是一个Android应用程序中的方法,getQueryCursor的作用是获取符合条件的媒体文件的光标。如果提供了AsyncQueryHandler,它会异步启动媒体查询操作,否则将在UI线程中进行查询。参数filter是一个字符串,用于过滤查询结果。getQueryCursor的返回值是一个Cursor对象,包含符合条件的媒体文件的信息。
相关问题
The argument type 'String' can't be assigned to the parameter type 'Source'. (Documentation)
感谢您提供的错误信息。根据错误消息,您遇到的问题是参数类型不匹配的错误。最新版本的audioplayers插件在播放音频时,要求将音频文件的路径作为Source类型的参数传递,而不是简单的字符串。
要解决这个问题,您可以尝试使用Uri.parse()方法将音频文件的路径转换为Source类型。以下是一个示例:
```dart
import 'package:audioplayers/audioplayers.dart';
import 'package:audioplayers/audio_cache.dart';
AudioPlayer audioPlayer = AudioPlayer();
AudioCache audioCache = AudioCache();
play() async {
String audioPath = 'path/to/audio/file.mp3';
var uri = Uri.parse(audioPath);
await audioPlayer.play(uri.toString());
}
```
在这个示例中,我们使用了`Uri.parse()`方法将音频路径转换为Uri对象,并使用`uri.toString()`将其转换为字符串形式。然后,通过调用`audioPlayer.play()`方法来播放音频文件。
请确保将'path/to/audio/file.mp3'替换为您实际的音频文件路径。如果仍然遇到问题,请提供更多的细节,以便我能够更好地帮助您。
import execjs import requests from lxml import etree def getRsa(u, p, lt): """ 加密方法 :param u:账号 :param p:密码 :param lt:lt :return:加密值 """ jsPath = r'./des.js' with open(jsPath, "r") as file: desJsCode = file.read() desJsFunction = execjs.compile(desJsCode) rsa = desJsFunction.call("strEnc", u + p + lt, "1", "2", "3") return rsa """ ---------------------------------------------------------------------------------- 第一次请求获取lt和execution的数值 """ header = { "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36' } loginUrl = """http://cas.upc.edu.cn/cas/login?service=http%3A%2F%2Fjwxt.upc.edu.cn%2Fneusoftcas.jsp""" session = requests.session() one = session.get(loginUrl) loginPageHtml = etree.HTML(one.text) lt = loginPageHtml.xpath(r'//*[@id="lt"]/@value')[0] execution = loginPageHtml.xpath(r'//*[@name="execution"]/@value')[0] u = '2009050216' p = '20020528lykLYK.' ul = len(u) pl = len(p) rsa = getRsa(u, p, lt) _eventId = "submit"
下面是相应的Dart代码实现:
```
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:html/parser.dart' show parse;
import 'package:html/dom.dart';
Future<String> getRsa(String u, String p, String lt) async {
/* 加密方法 */
File jsFile = File('./des.js');
String desJsCode = await jsFile.readAsString();
var context = await execjs.createContext(desJsCode);
String rsa = await context.callMethod("strEnc", [u + p + lt, "1", "2", "3"]);
return rsa;
}
Future<void> main() async {
/* 第一次请求获取lt和execution的数值 */
var headers = {
"User-Agent":
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
};
var loginUrl =
"http://cas.upc.edu.cn/cas/login?service=http%3A%2F%2Fjwxt.upc.edu.cn%2Fneusoftcas.jsp";
var session = http.Client();
var response = await session.get(Uri.parse(loginUrl), headers: headers);
var document = parse(response.body);
var lt = document.querySelector('#lt')?.attributes['value'] ?? "";
var execution = document.querySelector('[name="execution"]')?.attributes['value'] ?? "";
var u = '2009050216';
var p = '20020528lykLYK.';
var rsa = await getRsa(u, p, lt);
var _eventId = "submit";
}
```
需要注意的是,由于Dart是一门静态类型语言,因此需要显式地声明变量类型。此外,Dart中没有像Python中的execjs库一样可以直接使用JavaScript代码,因此需要使用dart-js库来实现JavaScript代码的调用。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)