Work on to stop playing of recording
This commit is contained in:
@@ -3,6 +3,7 @@ package com.tutpro.baresip
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.media.MediaPlayer
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -10,6 +11,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
@@ -76,8 +78,15 @@ class CallDetailsAdapter(private val ctx: Context, private val rows: ArrayList<C
|
|||||||
val recording = rows[position].recording
|
val recording = rows[position].recording
|
||||||
if (recording[0] != "") {
|
if (recording[0] != "") {
|
||||||
viewHolder.durationView.typeface = Typeface.DEFAULT_BOLD
|
viewHolder.durationView.typeface = Typeface.DEFAULT_BOLD
|
||||||
|
var players: Array<MediaPlayer>? = null
|
||||||
viewHolder.durationView.setOnClickListener {
|
viewHolder.durationView.setOnClickListener {
|
||||||
Utils.playRecording(ctx, recording)
|
if (players == null || (!players!![0].isPlaying && !players!![1].isPlaying)) {
|
||||||
|
players = Utils.playRecording(ctx, recording)
|
||||||
|
} else {
|
||||||
|
players!![0].stop()
|
||||||
|
players!![1].stop()
|
||||||
|
players = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -995,9 +995,10 @@ object Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playRecording(ctx: Context, recording: Array<String>) {
|
fun playRecording(ctx: Context, recording: Array<String>): Array<MediaPlayer> {
|
||||||
Log.d(TAG, "Playing recording $recording")
|
Log.d(TAG, "Playing recording $recording")
|
||||||
val decPlayer = MediaPlayer()
|
val decPlayer = MediaPlayer()
|
||||||
|
val encPlayer = MediaPlayer()
|
||||||
decPlayer.apply {
|
decPlayer.apply {
|
||||||
setAudioAttributes(
|
setAudioAttributes(
|
||||||
AudioAttributes.Builder()
|
AudioAttributes.Builder()
|
||||||
@@ -1006,7 +1007,6 @@ object Utils {
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
setOnPreparedListener {
|
setOnPreparedListener {
|
||||||
val encPlayer = MediaPlayer()
|
|
||||||
encPlayer.apply {
|
encPlayer.apply {
|
||||||
setAudioAttributes(
|
setAudioAttributes(
|
||||||
AudioAttributes.Builder()
|
AudioAttributes.Builder()
|
||||||
@@ -1058,6 +1058,7 @@ object Utils {
|
|||||||
Log.e(TAG, "decPlayer Exception: $e")
|
Log.e(TAG, "decPlayer Exception: $e")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return arrayOf(encPlayer, decPlayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
|||||||
+1
-1
Submodule libbaresip-android updated: 9fe7bd9293...86b8206a2f
Reference in New Issue
Block a user