Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TopPay
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
qyw
TopPay
Commits
77725a94
Commit
77725a94
authored
Dec 20, 2018
by
qyw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update file
parent
72855ff1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
1 deletions
+80
-1
MainActivity.java
TOP_Pay/app/src/main/java/com/ifavine/pay/ui/activity/MainActivity.java
+3
-1
SoundPlayUtils.java
TOP_Pay/app/src/main/java/com/ifavine/pay/utils/SoundPlayUtils.java
+77
-0
No files found.
TOP_Pay/app/src/main/java/com/ifavine/pay/ui/activity/MainActivity.java
View file @
77725a94
...
...
@@ -659,7 +659,9 @@ public class MainActivity extends BaseActivity {
@Override
public
void
onFailure
(
Call
<
CommonResponse
<
String
>>
call
,
Throwable
t
)
{
playUtils
.
play
(
1
);
if
(
playUtils
!=
null
)
{
playUtils
.
play
(
1
);
}
tv_pay_status
.
setText
(
"请求超时,请重试"
);
tv_pay_status
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
red
));
}
...
...
TOP_Pay/app/src/main/java/com/ifavine/pay/utils/SoundPlayUtils.java
0 → 100644
View file @
77725a94
package
com
.
ifavine
.
pay
.
utils
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.media.SoundPool
;
import
com.ifavine.pay.R
;
import
java.util.HashMap
;
/**
* Created by Administrator on 2018/12/20.
*/
public
class
SoundPlayUtils
{
// SoundPool对象
public
static
SoundPool
mSoundPlayer
=
new
SoundPool
(
20
,
AudioManager
.
STREAM_MUSIC
,
5
);
public
static
SoundPlayUtils
soundPlayUtils
;
// 上下文
static
Context
mContext
;
private
static
HashMap
<
Integer
,
Integer
>
data
=
new
HashMap
<
Integer
,
Integer
>();
/**
* 初始化
* 初始化音乐池 播发喇叭的 BaseApplication初始化 方法里面用
*
* @param context
*/
public
static
SoundPlayUtils
init
(
Context
context
)
{
if
(
soundPlayUtils
==
null
)
{
soundPlayUtils
=
new
SoundPlayUtils
();
}
// 初始化声音
mContext
=
context
;
/**
* 参数1:加载音乐流第多少个 (只用了俩个音乐) 2:设置音乐的质量 音乐流 3:资源的质量 0
*/
data
.
put
(
200
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
success
,
1
));
data
.
put
(
1
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
fail
,
1
));
data
.
put
(
500
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s500
,
1
));
data
.
put
(
501
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s501
,
1
));
data
.
put
(
502
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s502
,
1
));
data
.
put
(
503
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s503
,
1
));
data
.
put
(
504
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s504
,
1
));
data
.
put
(
505
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s505
,
1
));
data
.
put
(
506
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s506
,
1
));
data
.
put
(
507
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s507
,
1
));
data
.
put
(
508
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s508
,
1
));
data
.
put
(
509
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s509
,
1
));
data
.
put
(
510
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s510
,
1
));
data
.
put
(
511
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s511
,
1
));
data
.
put
(
512
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s512
,
1
));
data
.
put
(
513
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s513
,
1
));
data
.
put
(
514
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s514
,
1
));
data
.
put
(
515
,
mSoundPlayer
.
load
(
mContext
,
R
.
raw
.
s515
,
1
));
return
soundPlayUtils
;
}
/**
* 播放声音
*
* @param soundID 设置声音
*/
public
static
void
play
(
int
soundID
)
{
if
(
data
.
containsKey
(
soundID
))
{
mSoundPlayer
.
play
(
data
.
get
(
soundID
),
1
,
1
,
0
,
0
,
1
);
}
else
{
mSoundPlayer
.
play
(
data
.
get
(
1
),
1
,
1
,
0
,
0
,
1
);
}
}
public
static
void
release
()
{
mSoundPlayer
.
release
();
}
}
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