- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发一个包含视频 View 的应用程序,这是我的问题
我试过的代码:
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView); Uri video = Uri.parse("youtube.com/watch?v=8mIOkkkA2jA";);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
请大家解释一下如何实现这一目标?提前致谢!!!!!!
最佳答案
注意:仅适用于 android 手机(不适用于平板电脑)
private class YourAsyncTask extends AsyncTask<Void, Void, Void>
{
ProgressDialog progressDialog;
@Override
protected void onPreExecute()
{
super.onPreExecute();
progressDialog = ProgressDialog.show(AlertDetail.this, "", "Loading Video wait...", true);
}
@Override
protected Void doInBackground(Void... params)
{
try
{
String url = "http://www.youtube.com/watch?v=1FJHYqE0RDg";
videoUrl = getUrlVideoRTSP(url);
Log.e("Video url for playing=========>>>>>", videoUrl);
}
catch (Exception e)
{
Log.e("Login Soap Calling in Exception", e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
progressDialog.dismiss();
/*
videoView.setVideoURI(Uri.parse("rtsp://v4.cache1.c.youtube.com/CiILENy73wIaGQk4RDShYkdS1BMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
videoView.setMediaController(new MediaController(AlertDetail.this));
videoView.requestFocus();
videoView.start();*/
videoView.setVideoURI(Uri.parse(videoUrl));
MediaController mc = new MediaController(AlertDetail.this);
videoView.setMediaController(mc);
videoView.requestFocus();
videoView.start();
mc.show();
}
}
public static String getUrlVideoRTSP(String urlYoutube)
{
try
{
String gdy = "http://gdata.youtube.com/feeds/api/videos/";
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
String id = extractYoutubeId(urlYoutube);
URL url = new URL(gdy + id);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
Document doc = documentBuilder.parse(connection.getInputStream());
Element el = doc.getDocumentElement();
NodeList list = el.getElementsByTagName("media:content");///media:content
String cursor = urlYoutube;
for(int i = 0; i < list.getLength(); i++)
{
Node node = list.item(i);
if(node != null)
{
NamedNodeMap nodeMap = node.getAttributes();
HashMap<String, String> maps = new HashMap<String, String>();
for (int j = 0; j < nodeMap.getLength(); j++)
{
Attr att = (Attr) nodeMap.item(j);
maps.put(att.getName(), att.getValue());
}
if(maps.containsKey("yt:format"))
{
String f = maps.get("yt:format");
if (maps.containsKey("url"))
{
cursor = maps.get("url");
}
if (f.equals("1"))
return cursor;
}
}
}
return cursor;
}
catch(Exception ex)
{
Log.e("Get Url Video RTSP Exception======>>", ex.toString());
}
return urlYoutube;
}
protected static String extractYoutubeId(String url) throws MalformedURLException
{
String id = null;
try
{
String query = new URL(url).getQuery();
if (query != null)
{
String[] param = query.split("&");
for (String row : param)
{
String[] param1 = row.split("=");
if (param1[0].equals("v"))
{
id = param1[1];
}
}
}
else
{
if(url.contains("embed"))
{
id = url.substring(url.lastIndexOf("/") + 1);
}
}
}
catch(Exception ex)
{
Log.e("Exception", ex.toString());
}
return id;
}
关于android - 如何获取 RTSP URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8150074/
我有一个简单的 Rtsp 客户端...客户端将 Rtsp 命令发送到 Rtsp 服务器并从服务器获取 RTP 数据包。 The problem is that after a time( about
所以我正在尝试创建一个流式传输音乐的 RTSP 服务器。 我不明白服务器如何播放音乐,不同的请求会得到当时正在播放的内容。 所以,整理我的问题: 1)服务器如何播放音乐文件? 2) 对服务器的请求如何
我已经安装 gst-rtsp-server我想尝试一个简单的代码。但是在编译时我收到以下错误: In function `main': test-launch01.c:(.text+0x64): un
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我刚刚开始研究流媒体库和底层协议(protocol)。我了解 rtsp/rtp 流媒体以及这两种协议(protocol)的用途。但是,如果我们需要 IP 地址、编解码器和 rtsp/rtp 协议(pr
我想从 Live-CAM 捕获 Rtsp 流,然后我想将其重新流式传输到另一个 Rtsp 服务器。 基本上,我的计算机将使用 FFMpeg 作为中继服务器。 我已经尝试过这个临时命令,但我无法让它工作
我正在使用 java web 应用程序使用 rtsp 从 IP 摄像机检索视频; rtsp url 在 url 本身中嵌入了用户名/密码,这似乎很不安全。例如rtsp://用户:密码@ip/... 有
对不起,我的英语不好 我正在为 rtsp 通信程序工作 此 RTSP 服务器在我的 SETUP 请求中回复 459 错误(不允许聚合操作) 我对此一无所知。 请帮我。我做错了什么? ==== Mess
对于这个问题的普遍性,我深表歉意。我尝试了很多东西,但似乎没有任何效果。我有服务器? (我们称它为 服务器 A)驻留在局域网中,那里也有一个 IP 网络摄像头。该网络摄像头不断在地址上提供 RTSP
对于这个问题的普遍性,我深表歉意。我尝试了很多东西,但似乎没有任何效果。我有服务器? (我们称它为 服务器 A)驻留在局域网中,那里也有一个 IP 网络摄像头。该网络摄像头不断在地址上提供 RTSP
我有一个 RTSP 视频源 (h265),我可以使用 VLC 显示它。我想将流分成两部分,一个以原始分辨率(使用 h265 编码),另一个以新的较低分辨率(使用 h264 编码)。这两个新流也应该是
实时流协议(protocol) (RTSP) 版本 1.0 发布为 RFC 2326 1998 年。 现在将近 20 年后,2.0 版发布为 RFC 7826 2016 年 12 月。 我想知道这些更
我想使用 Kurento 作为媒体服务器,它将 WebRTC 作为输入并提供 RTSP 流作为 url:rtsp://kurento/streamName 这可能吗? 我看到了https://gith
我正在使用 rtsp-simple-server ( https://github.com/aler9/rtsp-simple-server ) 并向 RTSP 服务器提供 FFMPEG 流。 我使用
关注:https://github.com/kyriesent/node-rtsp-stream和 How to display IP camera feed from an RTSP url ont
我目前有一个采用 H.264 编码的 IP 摄像机流式视频 (RTSP)。 我想使用 FFmpeg 将此 H.264 编码流转换为另一个 RTSP 流,但 MPEG-2 编码。我该怎么做?我应该使用哪
我目前正在为 Android 设备开发通过 RTSP/UDP 进行的视频流。我的目标是通过 4G 蜂窝网络流式传输视频。我面临的问题是所使用的方法不适用于 Samsung Galaxy Core SM
获取 [rtsp @ 000002aa9df0cb80] 方法设置失败:500 内部服务器错误 当我尝试在 opencv python 中流式传输 rtsp 相机但一段时间后它可以正常工作几分钟并且不
我是这个论坛的新手,我的英语水平不是最好的! 我有一个网站,在那里我发布了摄像机的视频流,以显示在嵌套时间现场发生的事情!一个具有高 IT 技能的人为我构建了一个小服务器用于重新流 (Datarhei
我收到一个 HTTP 错误 400,以响应下面显示的函数正在处理的以下 RTSP URL。 描述 rtsp://root:pass@192.168.1.47/axis-media/media.amp
我是一名优秀的程序员,十分优秀!