why i cant play raw video in my app? did i miss something in my code? everytime i click the name of video in my listview this error appear in my logcat 2020-11-22 12:34:40.306 8395-8426/com.ncf.fitnessandexercise E/MediaPlayerNative: error (1, -2147483648) 2020-11-22 12:34:40.325 8395-8395/com.ncf.fitnessandexercise E/MediaPlayer: Error (1,-2147483648) and
this
public class Zumba extends AppCompatActivity {
VideoView videoView;
ListView listView;
ArrayList<String> videoList;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zumba);
videoView=findViewById(R.id.videoview);
listView=findViewById(R.id.lvideo);
videoList= new ArrayList<>();
videoList.add("Basic_Zumba_Steps_for_Quick_Weight_Loss_Fitness");
videoList.add("Closer_Zumba_Live_Love_Party");
videoList.add("Senorita_Zumba_Dance_Fitness");
videoList.add("Short_Zumba_Dance_Workout_for_Beginners");
adapter= new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,videoList);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
break;
case 1:
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video2));
break;
case 2:
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video3));
break;
case 3:
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video4));
break;
default:
break;
}
videoView.setMediaController(new MediaController(Zumba.this));
videoView.requestFocus();
videoView.start();
}
});
}
}
this is my xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ncf.fitnessandexercise.Zumba">
<VideoView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/videoview"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"/>
<ListView
android:id="@+id/lvideo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/videoview">
</ListView>
</RelativeLayout>
from cant play raw video in android studio using java
No comments:
Post a Comment