我试图实现一个播放默认通知声音的PlaySound()方法。它确实很有效。这是代码:
public void PlaySound()
{
MediaPlayer mediaPlayer = new MediaPlayer();
var notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification);
mediaPlayer.SetDataSource(Application.Context, notification);
Ringtone r = RingtoneManager.GetRingtone(Application.Context, notification);
mediaPlayer.SetAudioStreamType(r.StreamType);
mediaPlayer.Prepare();
mediaPlayer.Start();
}
然而,编译器告诉我不推荐使用r.StreamType。我查看了不同的地点,但无法找到新的'获取StreamType的方法。谁知道?
答案 0 :(得分:1)
API 21添加Traceback (most recent call last):
File "C:/Users/dell/Desktop/crossword.py", line 6, in <module>
b = pytesseract.image_to_string(a)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, in _execute_child
startupinfo)
PermissionError: [WinError 5] Access denied.
以替换MediaPlayer.SetAudioStreamType
,因此您可以执行运行时检查以确定要使用的API方法:
mediaPlayer.SetAudioStreamType