package com.weiny;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.test.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MmsPlayerActivity extends Activity {
private Button btnPlay;
Map<String, String> map = new HashMap<String, String>();
private View.OnClickListener buttonListener = new View.OnClickListener() {
public void onClick(View paramView) {
MmsPlayerActivity.this.openPlayer(MmsPlayerActivity.this.edtMms
.getText().toString());
}
};
private EditText edtMms;
private DecoderThread mthread;
private int out = 0;
private String szFileName = "/mnt/sdcard/mms.wma";
private mmsTrack track;
static {
try {
System.loadLibrary("mmsPlayer");
Log.v("MMS", "load lib success");
} catch (UnsatisfiedLinkError localUnsatisfiedLinkError) {
localUnsatisfiedLinkError.printStackTrace();
}
}
private void closePlayer() {
this.mthread.stop();
this.mthread = null;
}
private native int closemms();
private native byte[] getmmsBytes();
private native int getmmslistsize();
private native int initmms();
private int javawmaDecoder() {
int i = 0;
try {
i = wmaDecoder();
} catch (Exception localException) {
localException.printStackTrace();
Log.e("mms", "javawmaDecoder 发生异常" + localException.getMessage());
}
return i;
}
private void openPlayer(String paramString) {
this.mthread = new DecoderThread();
this.mthread.SetUrl(paramString);
this.mthread.start();
}
private native int openmms(String paramString);
private int startPlay(String paramString) {
int i = openmms(paramString);
if (i != 0) {
i = closemms();
return i;
}
int j = 0;
int l = 0;
PlayerThread localPlayerThread;
j = wmachannels();
l = wmabit();
i = javawmaDecoder();
this.track = new mmsTrack(wmasamplerate(), j, l);
this.track.init();
this.out = 1;
localPlayerThread = new PlayerThread();
localPlayerThread.start();
while (true) {
if (i <= 0)
this.out = 0;
try {
i = javawmaDecoder();
} catch (Exception localException) {
localException.printStackTrace();
Log.e("mms", localException.getMessage());
break;
}
}
return i;
}
private native int wmaDecoder();
private native int wmaalign();
private native int wmabit();
private native int wmabytespersec();
private native int wmachannels();
private native int wmasamplerate();
private native int wmasamplesize();
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.main);
this.btnPlay = ((Button) findViewById(R.id.btn));
this.edtMms = ((EditText) findViewById(R.id.ed));
this.edtMms.setText("mms://live.cri.cn/oldies");
this.btnPlay.setOnClickListener(this.buttonListener);
initmms();
}
public void onDestroy() {
closePlayer();
super.onDestroy();
}
private class DecoderThread extends Thread {
private String szMmsUrl;
private DecoderThread() {
}
public void SetUrl(String paramString) {
this.szMmsUrl = ("file://" + paramString);
}
public void run() {
try {
MmsPlayerActivity.this.startPlay(this.szMmsUrl);
sleep(1000L);
} catch (InterruptedException localInterruptedException) {
localInterruptedException.printStackTrace();
Log.e("mms", localInterruptedException.getMessage());
} catch (Exception localException) {
localException.printStackTrace();
Log.e("mms", localException.getMessage());
}
}
}
private class PlayerThread extends Thread {
private PlayerThread() {
}
public void run() {
int i = 0;
try {
while (true) {
if (MmsPlayerActivity.this.out == 0) {
MmsPlayerActivity.this.track.release();
return;
}
try {
// int k = MmsPlayerActivity.this.getmmslistsize();
// if ((i != 0) || (k >= 3))
// sleep(800L);
byte[] arrayOfByte = getmmsBytes();
Log.v("mms", "bytes.length=" + arrayOfByte.length);
MmsPlayerActivity.this.track.playAudioTrack(
arrayOfByte.clone(), 0, arrayOfByte.length);
} catch (Exception localInterruptedException) {
localInterruptedException.printStackTrace();
}
}
} catch (Exception j) {
// Log.e("mms", localException.getMessage());
// break label22:
// if (localInterruptedException == 0)
// {
// label71: j = 0;
// sleep(800L);
// }
// int j = 1;
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MmsPlayerActivity.zip (40个子文件)
MmsPlayerActivity
.externalToolBuilders
Ndk_Builder.launch 1KB
bin
classes.dex 8KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
MmsPlayerActivity.apk 897KB
classes
com
test
R$layout.class 364B
R$id.class 377B
R$drawable.class 377B
R$attr.class 310B
R.class 461B
R$string.class 397B
weiny
mmsTrack.class 1KB
MmsPlayerActivity.class 5KB
MmsPlayerActivity$DecoderThread.class 2KB
MmsPlayerActivity$PlayerThread.class 2KB
MmsPlayerActivity$1.class 1KB
resources.ap_ 11KB
TestNdk.apk 3.56MB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
values
strings.xml 180B
drawable-mdpi
ic_launcher.png 3KB
layout
main.xml 521B
obj
local
armeabi
libmmsPlayer.so 1.46MB
objs
TestNdk
com_ndk_test_JniClient.o 24KB
com_ndk_test_JniClient.o.d 4KB
libTestNdk.so 52KB
assets
gen
com
test
R.java 777B
jni
com_ndk_test_JniClient.c 736B
Android.mk 56KB
com_ndk_test_JniClient.h 719B
proguard.cfg 1KB
src
com
weiny
MmsPlayerActivity.java 5KB
mmsTrack.java 2KB
.project 1KB
.classpath 364B
project.properties 361B
AndroidManifest.xml 2KB
libs
armeabi
libmmsPlayer.so 1.46MB
共 40 条
- 1
ddsllpp
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页