简体   繁体   English

从受密码保护的Http目录播放音频文件

[英]Playing audio files from a password protected Http directory

I'm working on a little mobile application in Xamarin, i'm using XamarinMediaManager to play audio files from a URL using CrossMediaManager.Current.Play() which takes a string as URL. 我正在Xamarin中开发一个小型移动应用程序,我正在使用XamarinMediaManager通过CrossMediaManager.Current.Play()将URL作为字符串来播放来自URL的音频文件。 If i set up a name and a password on the directory that includes the MP3 is there a way for me to include the credentials and play it? 如果我在包含MP3的目录上设置了名称和密码,是否可以让我包含凭据并进行播放?

I could successfully access the password protected directory if i use an HttpWebResponse and set the credentials but i can't seem to find a way to pass that on to the CrossMediaManager 如果我使用HttpWebResponse并设置凭据,则可以成功访问受密码保护的目录,但是我似乎找不到找到将其传递给CrossMediaManager的方法

Thank you for the help in advance 谢谢您的提前帮助

To solve this problem i followed the recommendation that @Cheesebaron gave me and set an Authorization header to RequestHeaders on CrossMediaManager. 为了解决此问题,我遵循@Cheesebaron给我的建议,并在CrossMediaManager上将Authorization标头设置为RequestHeaders。 Here's the exact lines i used 这是我使用的确切行

string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("username" + ":" + "password")); 
CrossMediaManager.Current.RequestHeaders.Add("Authorization", "Basic " + svcCredentials);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM