Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
3cd106b6
Commit
3cd106b6
authored
Oct 11, 2021
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:ydl-media升级
parent
602356c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
26 deletions
+42
-26
config.gradle
config.gradle
+4
-4
MusePlugin.kt
m-muse/src/main/java/com/yidianling/muse/handler/MusePlugin.kt
+18
-14
AudioPlayer.kt
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
+20
-8
No files found.
config.gradle
View file @
3cd106b6
...
...
@@ -14,7 +14,7 @@ ext {
"m-dynamic"
:
"0.0.7.29"
,
"m-article"
:
"0.0.0.10"
,
"m-muse"
:
"0.0.28.2
6
"
,
"m-muse"
:
"0.0.28.2
7
"
,
"m-tests"
:
"0.0.24.15"
,
"m-course"
:
"0.0.43.28"
,
...
...
@@ -37,7 +37,7 @@ ext {
//第二步 若干
"ydl-webview"
:
"0.0.38.47"
,
"ydl-media"
:
"0.0.21.3
4
"
,
"ydl-media"
:
"0.0.21.3
5
"
,
"ydl-pay"
:
"0.0.18.19"
,
"m-audioim"
:
"0.0.49.29.41"
,
"ydl-flutter-base"
:
"0.0.14.32"
,
...
...
@@ -97,7 +97,7 @@ ext {
"m-dynamic"
:
"0.0.7.29"
,
"m-article"
:
"0.0.0.8"
,
"m-muse"
:
"0.0.28.2
6
"
,
"m-muse"
:
"0.0.28.2
7
"
,
"m-tests"
:
"0.0.24.15"
,
"m-course"
:
"0.0.42.70"
,
//-------------- 业务模块 API 层 --------------
...
...
@@ -119,7 +119,7 @@ ext {
//第二步 若干
"ydl-webview"
:
"0.0.38.47"
,
"ydl-media"
:
"0.0.21.3
4
"
,
"ydl-media"
:
"0.0.21.3
5
"
,
"ydl-pay"
:
"0.0.18.19"
,
"m-audioim"
:
"0.0.49.29.41"
,
"ydl-flutter-base"
:
"0.0.14.32"
,
...
...
m-muse/src/main/java/com/yidianling/muse/handler/MusePlugin.kt
View file @
3cd106b6
...
...
@@ -66,21 +66,25 @@ class MusePlugin : MethodChannel.MethodCallHandler {
}
// 播放音乐
ACTION_PLAY_MUSIC
->
{
var
musicUrl
:
String
?
=
methodCall
.
argument
<
String
>(
"url"
)
var
mContinue
:
Boolean
=
methodCall
.
argument
<
Boolean
>(
"mContinue"
)
!!
try
{
var
musicUrl
:
String
?
=
methodCall
.
argument
<
String
>(
"url"
)
var
mContinue
:
Boolean
=
methodCall
.
argument
<
Boolean
>(
"mContinue"
)
!!
if
(
mContinue
)
{
AudioPlayer
.
get
().
seekTo
(-
1
,
AudioPlayer
.
get
().
audioPosition
)
AudioPlayer
.
get
().
startPlayer
()
}
else
{
val
music
=
Music
()
music
.
path
=
musicUrl
?:
currentMusicUrl
music
.
album
=
""
music
.
artist
=
""
music
.
coverPath
=
""
music
.
title
=
""
PlayerFloatHelper
.
playingType
=
PlayTypeEnum
.
PLAY_TYPE_MUSE
AudioPlayer
.
get
().
singleCirclePlay
(
music
)
if
(
mContinue
)
{
AudioPlayer
.
get
().
seekTo
(-
1
,
AudioPlayer
.
get
().
audioPosition
)
AudioPlayer
.
get
().
startPlayer
()
}
else
{
val
music
=
Music
()
music
.
path
=
musicUrl
?:
currentMusicUrl
music
.
album
=
""
music
.
artist
=
""
music
.
coverPath
=
""
music
.
title
=
""
PlayerFloatHelper
.
playingType
=
PlayTypeEnum
.
PLAY_TYPE_MUSE
AudioPlayer
.
get
().
singleCirclePlay
(
music
)
}
}
catch
(
e
:
Exception
){
e
.
printStackTrace
()
}
}
// 暂停音乐
...
...
ydl-media/src/main/java/com/ydl/media/audio/AudioPlayer.kt
View file @
3cd106b6
...
...
@@ -3,7 +3,6 @@ package com.ydl.media.audio
import
android.content.Context
import
android.content.IntentFilter
import
android.media.AudioManager
import
android.media.MediaPlayer
import
android.os.Handler
import
android.os.Looper
import
com.tencent.bugly.Bugly.applicationContext
...
...
@@ -14,7 +13,10 @@ import com.ydl.media.audio.manager.NotifyManager
import
com.ydl.media.audio.model.Music
import
com.ydl.media.audio.receiver.NoisyAudioStreamReceiver
import
com.ydl.media.audio.utils.PlayProgressUtil
import
com.ydl.ydlcommon.utils.LogUtil
import
com.yidianling.common.tools.ToastUtil
import
tv.danmaku.ijk.media.player.IMediaPlayer
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
import
java.io.IOException
import
java.util.*
import
kotlin.collections.ArrayList
...
...
@@ -28,7 +30,7 @@ class AudioPlayer private constructor() {
private
var
context
:
Context
?
=
null
private
var
audioFocusManager
:
AudioFocusManager
?
=
null
var
mediaPlayer
:
MediaPlayer
?
=
null
var
mediaPlayer
:
I
MediaPlayer
?
=
null
private
var
handler
:
Handler
?
=
null
private
var
noisyReceiver
:
NoisyAudioStreamReceiver
?
=
null
private
var
noisyFilter
:
IntentFilter
?
=
null
...
...
@@ -117,7 +119,17 @@ class AudioPlayer private constructor() {
fun
init
(
context
:
Context
)
{
this
.
context
=
context
.
applicationContext
audioFocusManager
=
AudioFocusManager
(
context
)
mediaPlayer
=
MediaPlayer
()
mediaPlayer
=
IjkMediaPlayer
()
try
{
(
mediaPlayer
as
IjkMediaPlayer
).
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"dns_cache_clear"
,
1
)
}
catch
(
e
:
Exception
)
{
LogUtil
.
e
(
e
.
message
)
}
mediaPlayer
!!
.
setOnPreparedListener
{
mp
->
if
(
isPreparing
)
{
if
(
autoSaveProgress
)
{
...
...
@@ -134,7 +146,7 @@ class AudioPlayer private constructor() {
}
}
for
(
listener
in
listeners
)
{
listener
.
onPrepared
(
mediaPlayer
!!
.
duration
.
toLong
()
)
listener
.
onPrepared
(
mediaPlayer
!!
.
duration
)
}
}
mediaPlayer
!!
.
setOnBufferingUpdateListener
{
mp
,
percent
->
...
...
@@ -256,7 +268,7 @@ class AudioPlayer private constructor() {
try
{
mediaPlayer
!!
.
reset
()
mediaPlayer
!!
.
setDataSource
(
music
!!
.
path
)
mediaPlayer
!!
.
dataSource
=
music
!!
.
path
mediaPlayer
!!
.
prepareAsync
()
state
=
STATE_PREPARING
for
(
listener
in
listeners
)
{
...
...
@@ -422,10 +434,10 @@ class AudioPlayer private constructor() {
currentPosition
=
position
}
else
{
currentPosition
=
(
percent
*
mediaPlayer
!!
.
duration
/
100
).
toLong
()
currentPosition
=
percent
*
mediaPlayer
!!
.
duration
/
100
}
mediaPlayer
!!
.
seekTo
(
currentPosition
.
toInt
())
//////
mediaPlayer
!!
.
seekTo
(
currentPosition
)
MediaSessionManager
.
get
().
updatePlaybackState
()
if
(
autoSaveProgress
)
{
PlayProgressUtil
.
saveProgress
(
...
...
@@ -451,7 +463,7 @@ class AudioPlayer private constructor() {
* 获取音乐时长
*/
fun
getDuration
():
Long
{
return
mediaPlayer
?.
duration
?.
toLong
()
?:
0
return
mediaPlayer
?.
duration
?:
0
}
companion
object
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment