如何从URL播放音频/视频流? [英] How to Play Streaming Audio/Video from a url?

查看:1440
本文介绍了如何从URL播放音频/视频流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid系统。我使用的是Android OS 2.2。我想从以下网址播放流式音频和视频。我不知道该怎么办了点。 3天后OG的谷歌搜索我才知道,我必须使用媒体播放器和MediaController类。

我不得不使用$不同differend组合C $ CS在互联网上找到,但没有成功。

任何人都可以指导我怎么做的流式音频/视频播放。怎么样的用户界面,如果我们使用的MediaPlayer或者Controller类。是有什么东西在布局XML文件中有关这些。

如果没有,那么即使是请告诉我什么可能是code为。

请帮我。

解决方案

希望这有助于。

1 - 您的计算机(服务器)上安装VLC,去媒体 - >视频流(Ctrl + S键)

2 - 选择一个文件流或者,如果你想流你的摄像头或...点击捕​​获设备选项卡,然后执行配置,最后点击流按钮。

3在这里你应该做的流媒体服务器的配置,只要进入选项选项卡,并经过下面的命令:

<$p$p><$c$c>sout=#trans$c$c{v$c$cc=mp4v,vb=400,fps=10,width=176,height=144,a$c$cc=mp4a,ab=32,channels=1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}**

注意:与您的计算机的IP地址或运行VLC的任何服务器替换YOURCOMPUTER_SERVER_IP_ADDR ...

注意:您可以看到,视频codeC是被支持的Andr​​oid MP4V

4-去Eclipse和创造媒体回放时一个新的项目。创建VideoView对象,并在OnCreate()函数写一些code是这样的:

  mVideoView =(VideoView)findViewById(R.id.surface_view);
mVideoView.setVideoPath(rtsp://形式YOURCOMPUTER_SERVER_IP_ADDR:5544 /);
mVideoView.setMediaController(新的MediaController(本));
 

5运行在设备上的apk文件(不是模拟器,我没有检查),并等待播放启动。请考虑缓冲过程将持续约10秒......

I am new in Android. I am using android os 2.2. I am trying to play streaming audio and video from url. I don't know what to do for that. after 3 days og googling i come to know that I have to use mediaPlayer and MediaController classes.

I had use different differend combination of codes found on internet but not succeed.

Can anybody guide me what to do for streaming audio/video playing. What about the UI if we use MediaPlayer or Controller class. is there any thing to related these in xml file of layout.

if not then even please tell me what may be the code for that.

please help me.

解决方案

Hope this helps.

1- Install VLC on your computer (SERVER) and go to Media->Streaming (Ctrl+S)

2- select a file to stream or if you want to stream your webcam or... click on "Capture Device" tab and do the configuration and finally click on "Stream" button.

3- here you should do the streaming server configuration, just go to "Option" tab and past the following command:

sout=#transcode{vcodec=mp4v,vb=400,fps=10,width=176,height=144,acodec=mp4a,ab=32,channels=1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}**

NOTE: replace YOURCOMPUTER_SERVER_IP_ADDR with your computer IP address or any server which is running VLC...

NOTE: You can see, the video codec is MP4V which is supported by android.

4- go to eclipse and create a new project for media playbak. create a VideoView object and in the OnCreate() function write some code like this:

mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoPath("rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/");
mVideoView.setMediaController(new MediaController(this));

5- run the apk on the device (not simulator, i did not check it) and wait for the playback to be started. please consider the buffering process will take about 10 seconds...

这篇关于如何从URL播放音频/视频流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆