package cn.test.lee;

import android.app.Service;

import android.content.Intent;

import android.media.AudioManager;

import android.media.MediaPlayer;

import android.os.Bundle;

import android.os.IBinder;

public class MyPlayerService extends Service implements

MediaPlayer.OnPreparedListener {

private MediaPlayer mp1;

@Override

public IBinder onBind(Intent arg0) {

// TODO Auto-generated method stub

return null;

}

@Override

public void onStart(Intent intent, int startId) {

//mp1 = new MediaPlayer();

mp1 = MediaPlayer.create(this, R.raw.ai);

//mp1.reset();

mp1.setAudioStreamType(AudioManager.STREAM_MUSIC);

try {

//Bundle b = intent.getExtras();

//String videoPath = b.getString("videoPath");// "/mnt/sdcard/Video/Nobody.mp4";

//

//mp1.setDataSource(videoPath);// "/mnt/sdcard/Video/Nobody.mp4"

H264B3.3gp iceage.avi

test_h263.mp4 /sdcard/test.mp4

mp1.start();

//mp1.setOnPreparedListener(this);

} catch (Exception me) {

}

super.onStart(intent, startId);

}

@Override

public void onPrepared(MediaPlayer mp) {

// TODO Auto-generated method stub

mp.start();

}

@Override

public void onDestroy() {

mp1.release();

mp1 = null;

super.onDestroy();

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐