[英]Sorry, the video cannot be played
I have a video file in my local server. 我的本地服务器中有一个视频文件。 I am feeding my android code with the URL for the video file.
我正在用视频文件的URL填充我的android代码。 I have the video file in the video folder in Htdocs folder.
我的视频文件位于Htdocs文件夹的video文件夹中。 I have looked up same questions on stackoverflow, but couldn't find a solution to this.
我在stackoverflow上查找了相同的问题,但是找不到解决方案。 Please help.
请帮忙。 Here's the code..
这是代码。
public class WatchActivity extends Activity {
String SrcPath = "http://localhost/video/Coldplay - In My Place.mp4";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoURI(Uri.parse(SrcPath));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}
}
and here's the logcat for this 这是为此的logcat
10-06 12:02:11.473: D/MediaPlayer(332): Couldn't open file on client side, trying server side
10-06 12:02:11.523: E/MediaPlayer(332): error (1, -111)
10-06 12:02:11.723: E/MediaPlayer(332): Error (1,-111)
10-06 12:02:11.723: D/VideoView(332): Error: 1,-111
10-06 12:02:12.083: D/dalvikvm(332): GC_EXTERNAL_ALLOC freed 65K, 52% free 2609K/5379K, external 1813K/2137K, paused 50ms
First your link is wrong . 首先,您的链接有误。 Try with
10.0.2.2
instead of localhost
. 尝试使用
10.0.2.2
而不是localhost
。
Please try with .3gp
Video file . 请尝试使用
.3gp
视频文件。
Try with below link . 请尝试以下链接。 http://daily3gp.com/vids/747.3gp
http://daily3gp.com/vids/747.3gp
Add Internet Permission in Manifest file. 在清单文件中添加Internet权限。
<uses-permission android:name="android.permission.INTERNET"/>
Edit : 编辑:
VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://hermes.sprc.samsung.pl/widget/tmp/testh.3gp"));
videoView.requestFocus();
videoView.start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.