Ich habe seit ungefähr 2 Wochen gesucht und versucht, in der Lage zu sein, einen Video-Player in meiner Android App zu bekommen.VideoView Probleme in Android Studio
Ich habe viele Lösungen und sogar Youtube API versucht, aber es wird einfach nicht funktionieren. So, jetzt ich hoffe jemand kann den Code anschauen und erklären, was ich falsch mache, so dass ich diese
:) lernenDies ist die XML-Datei:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="no.test.videotest.MainActivity">
<VideoView
android:id="@+id/myVideo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
Und das die MainActivity ist:
package no.test.videotest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.net.Uri;
import android.widget.MediaController;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = (VideoView)findViewById(R.id.myVideo);
String vidAddress = "https://ia800201.us.archive.org/22/items/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4";
Uri vidUri = Uri.parse(vidAddress);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.start();
}
}
das einzige, was ich bekomme, wenn ich das auf mein Handy laden ist ein schwarzer Videoplayer ohne Kontrollen und ohne Video.
Hoffe jemand kann mir sagen, was hier falsch ist. Danke.
Überprüfung Manifest INTERNET Erlaubnis –
Ich habe die sicherstellen, enthalten. –
Joakim