Reputation: 162
I have an app that plays a video file from an URL that is the IP of a local server. The video plays fine when I run it in a browser or VLC player. But I don't want the IP address to be displayed when I play the video. Is there any way I can accomplish this? This is the code that plays the video file:
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class welcome extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button) findViewById(R.id.button1);{
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.1.4/videotest/Camera1.mp4"));
startActivity(browserIntent);
}});
}
}
}
Thanks
Upvotes: 1
Views: 2598
Reputation: 4910
You should use a VideoView but if you really want to run it inside a "browser" (webview) you can do something like this.
WebView intent
Intent intent = new Intent(context, WebViewActivity.class);
startActivity(intent);
WebViewActivity
public class WebViewActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://192.168.1.4/videotest/Camera1.mp4");
}
}
Layout
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Upvotes: 2