В настоящее время я создаю проект, в котором одним из действий является воспроизведение некоторого звука, хотя при разработке кода в XML существует ряд проблем, в которых в уведомлении упоминается «проблема рендеринга» после уведомления в моем XML:
Цветовые пространства не поддерживаются
, и это еще одна проблема:
java.lang.ArithmeticException: / by zero на co.mobiwise.library. InteractivePlayerView.calculatePastProgress (InteractivePlayerView.java:769) по адресу co.mobiwise.library.InteractivePlayerView.onDraw_Original (InteractivePlayerView.java:517) по адресу co.mobiwise.library.InteralayPlayerView.onDraw.View.Ov.Oj.avid.Ov. (View.java:20207) на android.view.View_Delegate.draw (View_Delegate.java:56) на android.view.View.draw (View.java:20177) на android.view.View.draw_Original (View.java:20077) на android.view.View_Delegate.draw (View_Delegate.java:68) на android.view.View.draw (View.java:19849) на android.view.ViewGroup.drawChild_Original (ViewGroup.java:4333) в android.view.ViewGroup_Delegate.drawChild (ViewGroup_Delegate.java:65) в android.view.ViewGroup.drawChild (ViewGroup.java:4333) в android.view.ViewGroup.dispatch. Java: 4112) на android.view.View.draw_Original (View.java:20075) на android.view.View_Delegate.draw (View_Delegate.java:68) на android.view.View.draw (View.java:19849) наandroid.view.ViewGroup.drawChild_Original (ViewGroup.java:4333) в android.view.ViewGroup_Delegate.drawChild (ViewGroup_Delegate.java:65) в android.view.ViewGroup.drawChild (ViewGroup.java:4333) в android.viewGview.dispatchDraw (ViewGroup.java:4112) в android.view.View.draw_Original (View.java:20075) в android.view.View_Delegate.draw (View_Delegate.java:68) в android.view.View.draw (Просмотреть. Java: 19849) в android.view.ViewGroup.drawChild_Original (ViewGroup.java:4333) в android.view.ViewGroup_Delegate.drawChild (ViewGroup_Delegate.java:65) в android.view.ViewGroup.drawChild (ViewGroup.java:433)андроид. view.ViewGroup.dispatchDraw (ViewGroup.java:4112) по адресу androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw (ConstraintLayout.java:2023) по адресу android.view.View.draw_Original (View.java:20210) в android.ee.view.draw (View_Delegate.java:56) на android.view.View.draw (View.java:20177) на android.view.View.draw_Original (View.java:20077) на android.view.View_Delegate.draw (View_Delegate. Java: 68) на android.view.View.draw (View.java:19849) на android.view.ViewGroup.drawChild_Original (ViewGroup.java:4333) на android.view.ViewGroup_Delegate.drawChild (ViewGroup_Delegate.java:65) наandroid.view.ViewGroup.drawChild (ViewGroup.java:4333) в android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112) в android.view.View.draw_Original (View.java:20075) в android.view.View_Delegate.draw (View_Delegate.java:68) на android.view.View.draw (View.java:19849) на android.view.ViewGroup.drawChild_Original (ViewGroup.java:4333) на android.view.ViewGroup_Delegate.drawChild (ViewGroup_Delegate). Ява: 65) вandroid.view.ViewGroup.drawChild (ViewGroup.java:4333) в android.view.ViewGroup.dispatchDraw (ViewGroup.java:4112) в android.view.View.draw_Original (View.java:20210) в android.view.View_Delegate.draw (View_Delegate.java:56) на android.view.View.draw (View.java:20177) на com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult (RenderSessionImpl.java:399) на com.android. layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult (RenderSessionImpl.java:551) в com.android.layoutlib.bridge.impl.RenderSessionImpl.render (RenderSessionImpl.java:420) в com.android.ridgeoutrenbb (BridgeRenderSession.java:120)на com.android.ide.common.rendering.api.RenderSession.render (RenderSession.java:151) на com.android.ide.common.rendering.api.RenderSession.render (RenderSession.java:133) на com.android.tools.idea. ThreadPoolExecutor.java:1149) на java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:624) на java.lang.Thread.run (Thread.java:748)
ЗдесьСодержимое моего XML:
<androidx.constraintlayout.widget.ConstraintLayout 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=".DoaHaji">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_gravity="center"
android:layout_weight="1.5"
android:layout_width="match_parent"
android:layout_height="0dp">
<co.mobiwise.library.InteractivePlayerView
android:id="@+id/ipv"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
app:imageCover="@drawable/testimage"
app:selectedAction1="@drawable/shuffle_selected"
app:selectedAction2="@drawable/like_selected"
app:selectedAction3="@drawable/replay_selected"
app:unselectedAction1="@drawable/shuffle_unselected"
app:unselectedAction2="@drawable/like_unselected"
app:unselectedAction3="@drawable/replay_unselected" />
<Button
android:id="@+id/btnPlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@color/color_trans"
android:text="@string/play"
android:textColor="@color/color_red"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="@string/juduldoa"
android:layout_marginStart="10dp" />
<ListView
android:id="@+id/listDoa"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/listdoa">
</ListView>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
и это мой java-код:
import androidx.appcompat.app.AppCompatActivity;
import co.mobiwise.library.InteractivePlayerView;
import co.mobiwise.library.OnActionClickedListener;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class DoaHaji extends AppCompatActivity implements OnActionClickedListener, AdapterView.OnItemClickListener {
private InteractivePlayerView ipv;
private Button control;
private MediaPlayer mediaPlayer;
private ListView listView;
private String[] number;
private Uri uri;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doahaji);
mediaPlayer = MediaPlayer.create(DoaHaji.this, R.raw.doaniathaji);
number = getResources().getStringArray(R.array.listdoa);
listView = (ListView) findViewById(R.id.listDoa);
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, number);
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
//call doa
Uri uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doaniathaji");
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv = (InteractivePlayerView) findViewById(R.id.ipv);
ipv.setMax(milli);
ipv.setProgress(0);
ipv.setOnActionClickedListener(this);
control = (Button) findViewById(R.id.btnPlay);
control.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!ipv.isPlaying()) {
ipv.start();
control.setText("PAUSE");
mediaPlayer.start();
} else {
ipv.stop();
control.setText("PLAY");
mediaPlayer.pause();
}
}
});
}
@Override
public void onActionClicked(int id) {
switch (id){
case 1:
Toast.makeText(DoaHaji.this, "Pilihan Suffled", Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(DoaHaji.this, "Pilihan Love", Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(DoaHaji.this, "Pilihan Repeat", Toast.LENGTH_SHORT).show();
break;
default:
break;
}
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
TextView textView = (TextView) view;
String parameterNilai = String.valueOf(textView.getText());
if(parameterNilai.equals("Doa Niat Haji")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doaniathaji");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doaniathaji);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
} else if (parameterNilai.equals("Doa Melontar Jumrah")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doamelontarjumrah");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doamelontarjumrah);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
} else if (parameterNilai.equals("Doa Niat Thawaf")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doaniatthawaf");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doaniatthawaf);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
}else if (parameterNilai.equals("Doa Talbiyah")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doatalbiyah");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doatalbiyah);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
} else if (parameterNilai.equals("Doa Thawaf Wada")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doathawafwada");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doathawafwada);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
} else if (parameterNilai.equals("Doa Waktu Tahallul")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doawaktutahallul");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doawaktutahallul);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
} else if (parameterNilai.equals("Doa Wukuf di Arafah")){
cekMusikPlay();
uri = Uri.parse("android.resource://com.panduanhaji.mita.panduanhaji/raw/doawukufdiarafah");
mediaPlayer = mediaPlayer.create(DoaHaji.this, R.raw.doawukufdiarafah);
MediaMetadataRetriever nmr = new MediaMetadataRetriever();
nmr.setDataSource(DoaHaji.this, uri);
String durastionString = nmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int milli = Integer.parseInt(durastionString);
milli = milli/1000;
ipv.setMax(milli);
ipv.setProgress(0);
cekMusikEnd();
}
}
private void cekMusikEnd() {
ipv.start();
control.setText("PAUSE");
mediaPlayer.start();
}
private void cekMusikPlay() {
if (ipv.isPlaying()){
ipv.stop();
control.setText("PLAY");
mediaPlayer.pause();
}
}
}
влияет ли это на цветовой код, который я применяю? это мой цвет XML:
<resources>
<color name="colorPrimary">#05c3f9</color>
<color name="colorPrimaryDark">#0691b8</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#ffffff</color>
<color name="color_red">#fff44336</color>
<color name="color_trans">#00f4364f</color>
</resources>
, потому что я действительно новичок, который ничего не знает о кодировании, я пытался написать код, созданный кем-то другим, но он использовал старую версию андроид-студии, и результаты оказались неудачными. применяется в Android Studio версии 3.5, это имеет эффект? Кто-нибудь может мне помочь? Я очень устал искать ответы на эту проблему.