是否可以将音频mp3文件转换为字符串数据以将数据发送到服务器,服务器将字符串数据返回到我的应用程序,我想将该数据转换为mp3文件并播放音频。
我正在使用此代码将mp3文件转换为字符串数据
public static String readFileAsString(String filePath) throws java.io.IOException {
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line, results = "";
while( ( line = reader.readLine() ) != null)
{
results += line;
}
reader.close();
return results;
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何从转换后的strind数据取回我的mp3文件。
如果可能的话怎么办?有人帮我
或任何其他解决方案,告诉我:我想将音频和视频文件传递到服务器,然后从服务器取回以在应用程序中使用。
我在 asp.net webapi 中使用以下代码进行音频流,以允许 Android 应用程序调用 api 并播放歌曲。
public class AudioController : ApiController
{
ITrackRepository _TrackRepo = new TrackRepository();
public AudioController()
{
}
public HttpResponseMessage Get(int id)
{
var trackd = _TrackRepo.GetPlayfilepath(id);
string filename = System.Web.HttpContext.Current.Server.MapPath(trackd.Select(x => x.FilePath).FirstOrDefault());
var audio = new AudioStream(filename);
string fileExtension = System.IO.Path.GetExtension(filename);
var response = Request.CreateResponse();
response.Content = new PushStreamContent(audio.WriteToStream, new MediaTypeHeaderValue("audio/" + fileExtension));
return response;
}
}
public class AudioStream
{
private readonly string _filename;
public AudioStream(string filename)
{
_filename = filename;
}
public …Run Code Online (Sandbox Code Playgroud) 我在服务器中有一个音频文件,所以我可以用url播放音频文件.下面是代码.如何在播放音频文件时显示进度条?
-(void)playselectedsong{
AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]];
[player play];
}
Run Code Online (Sandbox Code Playgroud) 我的应用程序允许用户访问通过网络播放有声读物的服务.我正在使用UIWebView来处理这个问题.
退出应用程序或设备进入睡眠状态时,音频将停止播放.由于我只是显示网页视图没有直接播放音频文件,我无法使用这些方法在后台播放音频.
但是,如果您通过Safari应用程序访问相同的链接,则在手机进入睡眠状态后,音频会继续播放.如何在我的应用程序中实现相同的效果?
我们的应用程序不断记录和处理来自iPhone麦克风的音频。
目前,我使用AVAudioRecorder和AVFoundation并将音频输入输出录制到8秒的“ .wav”文件中。
相反,我想连续将音频输入记录到缓冲区并处理8秒长的缓冲区块。
如何将音频输入记录到缓冲区中,如何从那里读取8秒长的块?
谢谢!
有一些标准方法可以向流媒体广播服务询问当前播放的歌曲吗?我目前以不同的方式为每个站点执行此操作,例如(SomaFM):
$wg=join("\n",`wget -q -O - https://somafm.com/secretagent/songhistory.html`);
$wg=~/\(Now\).*>([^<]*)<\/a><\/td><td>([^<]*)/s;
print "Secret Agent\n$1\n$2\n"
Run Code Online (Sandbox Code Playgroud)
或(Radio Svizzera Classica):
$wg=join("\n",`wget -q -O - http://www.radioswissclassic.ch/en`);
$wg=~/On Air.*?titletag">([^<]*).*?artist">([^<]*)/s;
print "Radio Svizzera Classic\n$1\n$2\n"
Run Code Online (Sandbox Code Playgroud)
...但我想知道是否有更标准的方法可以做到这一点,而不是依赖于下载迟早会改变的html页面
我无法播放 2 秒的小音频剪辑。我已经尝试了 stackOverflow 中提到的与此问题类似的每个排列。即使是似乎对其他人有用的解决方案,也没有任何东西对我有用。我不知道是因为我没有物理设备可以测试还是其他什么原因。
我收到“找不到活动”错误:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.category.ACTION_VIEW dat=R.raw.song_name.mp3 }
Run Code Online (Sandbox Code Playgroud)
我的播放音频的代码:
Uri uri = Uri.parse("R.raw.song_name.mp3");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("audio/*");
intent.setData(uri);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我的文件存储在:
res/raw/song_name.mp3
我没有对 AndroidManifest.xml 做任何额外的事情。我正在模拟器上运行这个应用程序。这是导致此错误的原因吗?
我正在使用 Twilio 语音流功能,但我不想使用 Twilio 录音功能。当 Twilio 开始向我的服务器发送语音流时,我想将其作为音频文件实时存储到磁盘中。
audio-streaming twilio nodejs-stream twilio-programmable-voice
我似乎想将我想在网站上流式传输的音频转换为audio/mp4; codecs="mp4a.40.2".
使用ffmpeg-cli-wrapper,我在此处使用以下命令转换我上传的音频文件:
ffmpeg -i /tmp/input.any -acodec aac -b:a 256000 /tmp/output.aac
Run Code Online (Sandbox Code Playgroud)
在客户端上,我创建一个像这样的 SourceBuffer:
ffmpeg -i /tmp/input.any -acodec aac -b:a 256000 /tmp/output.aac
Run Code Online (Sandbox Code Playgroud)
错误是:
铬合金:
NotSupportedError: Failed to load because no supported source was found.
Run Code Online (Sandbox Code Playgroud)
火狐浏览器:
NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable.
Run Code Online (Sandbox Code Playgroud)
audio/aac如果我使用mime-type创建 SourceBuffer :
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/mp4; codecs="mp4a.40.2"');
Run Code Online (Sandbox Code Playgroud)
音频在 Chrome 上正确播放,但 Firefox 说:
MediaSource.addSourceBuffer: Type not supported in MediaSource
Run Code Online (Sandbox Code Playgroud)
将命令更改为后
ffmpeg -i /tmp/input.any …Run Code Online (Sandbox Code Playgroud) With my iPad's iOS Safari, I can use Daily.co's video API to call other devices. But the moment I start recording my local microphone via the audio-recorder-polyfill library , everybody else will no longer be able to hear me, even though I can still hear them and share my camera. Even when the recording session ends, the audio call remains broken (though the audio-recorder works successfully).
It seems iOS specific, because I have no problems with my Surface's Windows …
mobile-safari audio-streaming video-conferencing web-mediarecorder webrtc-ios
audio-streaming ×10
ios ×3
android ×2
audio ×2
avfoundation ×1
c#-4.0 ×1
core-audio ×1
ffmpeg ×1
firefox ×1
iphone ×1
media-source ×1
streaming ×1
swift ×1
twilio ×1
uiwebview ×1
webrtc-ios ×1