Android MediaPlayer无法在平板电脑设备上运行

时间:2013-05-17 04:47:12

标签: android android-layout android-intent android-emulator

我开发了ShoutCastInternet Radio,我在移动设备上成功播放,但是相同的代码,如果我在平板电脑设备上执行,我无法播放流,我调试了我的代码,程序流程正在停止以下行,它无法转发到startMediaPlayer()方法,我曾使用过mMediaPlayer.prepareAsync()aslo

mMediaPlayer.prepare();

我的代码:

    /**
     * Initializes a StatefulMediaPlayer for streaming playback of the provided
     * stream url
     * 
     * @param streamUrl
     *            The URL of the stream to play.
     */
    public void initializePlayer(String streamUrl) {
        songurl = streamUrl;

        Log.d("service", "iam in initialize player");

        /*
         * if(mMediaPlayer!=null) { resetMediaPlaer(); }
         */
        mMediaPlayer = new MediaPlayer();
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        try {
            mMediaPlayer.setDataSource(streamUrl);
            // mMediaPlayer.setOnBufferingUpdateListener(this);
            mMediaPlayer.setOnInfoListener(this);
            // mMediaPlayer.setOnPreparedListener(this);
            mMediaPlayer.prepare();
            // mMediaPlayer.start();
        } catch (Exception e) {
            Log.e("MediaPlayerService", "error setting data source");
            // mMediaPlayer.setState(MPStates.ERROR);
        }
        /*
         * mMediaPlayer.setOnBufferingUpdateListener(this);
         * mMediaPlayer.setOnInfoListener(this); //
         * mMediaPlayer.setOnPreparedListener(this);
         * mMediaPlayer.prepareAsync();
         */
        startMediaPlayer();
    }


    /**
     * Starts the contained StatefulMediaPlayer and foregrounds the service to
     * support persisted background playback.
     */
    public void startMediaPlayer() {
        // mMediaPlayer.stop();
        // mMediaPlayer.release();
        // mMediaPlayer=mMediaPlayer1;
        Log.d("service",
                "iam in start mediaplayer" + mMediaPlayer.getCurrentPosition());
        // Context context = getApplicationContext();

        /*
         * //set to foreground Notification notification = new
         * Notification(android.R.drawable.ic_media_play, "MediaPlayerService",
         * System.currentTimeMillis()); Intent notificationIntent = new
         * Intent(this, TORiLTActivity.class);
         * notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         * PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
         * notificationIntent, 0);
         * 
         * CharSequence contentTitle = "MediaPlayerService Is Playing";
         * CharSequence contentText =
         * mMediaPlayer.getStreamStation().getStationLabel();
         * notification.setLatestEventInfo(context, contentTitle, contentText,
         * pendingIntent); startForeground(1, notification);
         */

        Log.d("MediaPlayerService", "startMediaPlayer() called");
        mMediaPlayer.start();
    }

logcat的:

05-16 16:18:02.573: D/connection(6989): connection:true
05-16 16:18:06.839: D/HS1(6989): onCreate
05-16 16:18:06.874: D/HS1(6989): onCreate>>
05-16 16:18:06.905: I/facebook(6989): connection
05-16 16:18:07.136: I/Ads(6989): To get test ads on this device, call adRequest.addTestDevice("CF95DC53F383F9A836FD749F3EF439CD");
05-16 16:18:07.257: I/dalvikvm(6989): Total arena pages for JIT: 11
05-16 16:18:07.339: D/lazyadapter(6989): dataTORi Classics - US Pacific
05-16 16:18:07.339: D/dalvikvm(6989): DexOpt: --- BEGIN 'ads35864.jar' (bootstrap=0) ---
05-16 16:18:07.460: D/webviewglue(6989): nativeDestroy view: 0x3251e8
05-16 16:18:07.464: D/dalvikvm(6989): GC_EXTERNAL_ALLOC freed 7044 objects / 606040 bytes in 71ms
05-16 16:18:07.468: D/lazyadapter(6989): dataTORi Classics - US Pacific
05-16 16:18:07.472: D/lazyadapter(6989): dataTORi Classics - US Eastern
05-16 16:18:07.480: D/lazyadapter(6989): dataTORi Classics - UK(GMT)
05-16 16:18:07.483: D/dalvikvm(6989): DexOpt: --- END 'ads35864.jar' (success) ---
05-16 16:18:07.483: D/dalvikvm(6989): DEX prep '/data/data/com.teluguone.torilt/cache/ads35864.jar': unzip in 0ms, rewrite 144ms
05-16 16:18:07.507: D/lazyadapter(6989): dataTORi Classics - IST
05-16 16:18:07.523: D/lazyadapter(6989): dataTORi Classics - Australia
05-16 16:18:07.526: D/lazyadapter(6989): dataTORi Generations - Ghantasala Era
05-16 16:18:07.534: D/lazyadapter(6989): dataTORi Generations - Illayaraja - SPB Era
05-16 16:18:07.538: D/lazyadapter(6989): dataTORi Generations - AR Rehman Era
05-16 16:18:07.612: I/Ads(6989): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"10588385027800554711","u_sd":1.5,"seq_num":"1","slotname":"a151948104adce5","u_w":400,"msid":"com.teluguone.torilt","js":"afma-sdk-a-v6.4.1","ms":"iSlmx8MDGSoStzndnqerF57udsjToRAUBWellinDkya6sCuwm-4FE6z-4l7o_dKKqljmiesC7Kd3KPZo1p3AgAxZSHBFuZknpTVw320iBWFvWQ2RWHiNTlKL0bBwgHx86av7zoYlxNcN9lIP8VkGjFiDoB_UV_xJ5iqjiEwrzNxJMGyQ1sP-rbn2L8_1emUMJu8ryYCZJqXVB7DNXpKTdIFqIPxnrGprSox8YJYGpz9LG1_TznXnJVjD3X96_KfbEQfYOv5np2E6EJ88UO31T32z-an8A1isa0go4c9W4vMHtiiwr9HPdpaf_VAvOFbADwHyoBk9nJlfOdPAEiv84Q","mv":"8016014.com.android.vending","isu":"CF95DC53F383F9A836FD749F3EF439CD","bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"1.android.com.teluguone.torilt","hl":"en","ad_pos":{"height":0,"visible":1,"y":181,"x":0,"width":900},"gnt":1,"u_h":682,"pt":1,"carrier":"40407","bas_on":0,"ptime":0,"u_audio":1});</script></head><body></body></html>
05-16 16:18:07.624: D/MainActivity(6989): service connected
05-16 16:18:07.624: D/if(6989): media null
05-16 16:18:07.624: D/service(6989): iam in initialize player
05-16 16:18:07.624: V/MediaPlayer-JNI(6989): native_setup
05-16 16:18:07.628: V/MediaPlayer(6989): constructor
05-16 16:18:07.628: V/MediaPlayer(6989): setListener
05-16 16:18:07.628: V/MediaPlayer-JNI(6989): setAudioStreamType: 3
05-16 16:18:07.628: V/MediaPlayer(6989): MediaPlayer::setAudioStreamType
05-16 16:18:07.628: V/MediaPlayer-JNI(6989): setDataSource: path http://38.101.195.5:9156/
05-16 16:18:07.628: V/MediaPlayer(6989): setDataSource(http://38.101.195.5:9156/)
05-16 16:18:07.640: V/MediaPlayer(6989): prepare

更新了Logcat:

05-17 11:13:22.623: D/dalvikvm(4359): DexOpt: load 1ms, verify 36ms, opt 0ms
05-17 11:13:22.627: D/lazyadapter(4340): dataTORi Classics - US Eastern
05-17 11:13:22.631: D/lazyadapter(4340): dataTORi Classics - UK(GMT)
05-17 11:13:22.643: D/dalvikvm(4340): DexOpt: --- END 'ads63728.jar' (success) ---
05-17 11:13:22.643: D/dalvikvm(4340): DEX prep '/data/data/com.teluguone.torilt/cache/ads63728.jar': unzip in 0ms, rewrite 127ms
05-17 11:13:22.659: D/lazyadapter(4340): dataTORi Classics - IST
05-17 11:13:22.663: D/lazyadapter(4340): dataTORi Classics - Australia
05-17 11:13:22.663: D/lazyadapter(4340): dataTORi Generations - Ghantasala Era
05-17 11:13:22.678: D/lazyadapter(4340): dataTORi Generations - Illayaraja - SPB Era
05-17 11:13:22.702: D/MainActivity(4340): service connected
05-17 11:13:22.702: D/if(4340): media null
05-17 11:13:22.702: D/service(4340): iam in initialize player
05-17 11:13:22.702: V/MediaPlayer-JNI(4340): native_setup
05-17 11:13:22.702: V/MediaPlayer(4340): constructor
05-17 11:13:22.702: V/MediaPlayer(4340): setListener
05-17 11:13:22.702: V/MediaPlayer-JNI(4340): setAudioStreamType: 3
05-17 11:13:22.702: V/MediaPlayer(4340): MediaPlayer::setAudioStreamType
05-17 11:13:22.702: V/MediaPlayer-JNI(4340): setDataSource: path http://38.101.195.5:9156/
05-17 11:13:22.702: V/MediaPlayer(4340): setDataSource(http://38.101.195.5:9156/)
05-17 11:13:22.702: V/PVPlayer(2394): PVPlayer constructor
05-17 11:13:22.702: V/PVPlayer(2394): construct PlayerDriver
05-17 11:13:22.702: V/PlayerDriver(2394): constructor
05-17 11:13:22.702: V/PlayerDriver(2394): OpenCore hardware module not found
05-17 11:13:22.702: V/PlayerDriver(2394): start player thread
05-17 11:13:22.702: V/AlarmManager(2487): Checked for alarms... rtc=1368769402705, elapsed=1174139
05-17 11:13:22.702: V/AlarmManager(2487): sending alarm Alarm{482b3d10 type 2 cellfish.spidermanlwp}
05-17 11:13:22.713: V/PlayerDriver(2394): startPlayerThread
05-17 11:13:22.713: V/PlayerDriver(2394): InitializeForThread
05-17 11:13:22.713: V/PlayerDriver(2394): OMX_MasterInit
05-17 11:13:22.733: V/PlayerDriver(2394): OsclScheduler::Init
05-17 11:13:22.733: V/PlayerDriver(2394): CreatePlayer
05-17 11:13:22.772: D/(2394): SISO TEST registering PVMFRecognizerPluginFactory
05-17 11:13:22.780: D/(2394): SISO TEST registering PVMFRecognizerPluginFactory success
05-17 11:13:22.780: V/PlayerDriver(2394): AddToScheduler
05-17 11:13:22.780: V/PlayerDriver(2394): PendForExec
05-17 11:13:22.780: V/PlayerDriver(2394): OsclActiveScheduler::Current
05-17 11:13:22.780: V/PlayerDriver(2394): StartScheduler
05-17 11:13:22.780: V/PVPlayer(2394): send PLAYER_SETUP
05-17 11:13:22.780: V/PlayerDriver(2394): Send player code: 2
05-17 11:13:22.780: V/PlayerDriver(2394): CommandCompleted
05-17 11:13:22.780: V/PlayerDriver(2394): Completed command PLAYER_SETUP status=1
05-17 11:13:22.780: V/PVPlayer(2394): setDataSource(http://38.101.195.5:9156/)
05-17 11:13:22.780: I/PlayerDriver(2394): PlayerDriver::isProtectedFile(http://38.101.195.5:9156/)
05-17 11:13:22.780: V/PlayerDriver(2394): File EXT is : 156/
05-17 11:13:22.780: E/PlayerDriver(2394): PlayerDriver::it is a not Protected file
05-17 11:13:22.780: D/Before Prepare(4340): Before Prepare
05-17 11:13:22.780: V/MediaPlayer(4340): prepare
05-17 11:13:22.780: V/PVPlayer(2394): prepareAsync
05-17 11:13:22.780: V/PVPlayer(2394):   data source = http://38.101.195.5:9156/
05-17 11:13:22.780: V/PlayerDriver(2394): Send player code: 3
05-17 11:13:22.784: V/PlayerDriver(2394): handleSetDataSource
05-17 11:13:22.784: V/PlayerDriver(2394): handleSetDataSource- scanning for extension
05-17 11:13:22.791: E/(2394): IIIIIII Inside Constructor of PVMFMemoryBufferWriteDataStreamImpl
05-17 11:13:22.795: I/Ads(4340): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"17067838220037024582","u_sd":1.5,"seq_num":"1","slotname":"a151948104adce5","u_w":400,"msid":"com.teluguone.torilt","js":"afma-sdk-a-v6.4.1","ms":"oEgs7AKryna8KvMqjp_veS4HICbxcQXk86Dgp8cc21LM7ksOsDLF36O3QFRPR4Y204YM2NfWWbvnxM8Jr8KEi-j-MXNUqBlyS31OWOOiSo0v1iUYlZsYGhG_EAleiYSLv8oWMvUvTPSP7eVF_uUtssWKhL7YQZHs3YvpAKtrA3wDx_dOOhLSwDZdnnFHjy3zTUK8JQN6K4T-p-7Wpiyyz7Zowa_-vqgkd0_qzFelKxEKVGnq1NszZLUPY2RPJcwlpx47MudnL4n4hRi2DnZRdDQodDsQY2ITW_lLgw4DSaI0cQJNc7WvHT26WUIwUscFot5Nd4tqxf7wxBGN5tAuAw","mv":"8016014.com.android.vending","isu":"CF95DC53F383F9A836FD749F3EF439CD","bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"1.android.com.teluguone.torilt","hl":"en","ad_pos":{"height":0,"visible":1,"y":181,"x":0,"width":900},"gnt":1,"u_h":682,"pt":1,"carrier":"40407","bas_on":0,"ptime":0,"u_audio":1});</script></head><body></body></html>
05-17 11:13:22.799: V/PlayerDriver(2394): CommandCompleted
05-17 11:13:22.799: V/PlayerDriver(2394): Completed command PLAYER_SET_DATA_SOURCE status=1
05-17 11:13:22.799: V/PVPlayer(2394): run_init s=0, cancelled=0
05-17 11:13:22.799: V/PlayerDriver(2394): Send player code: 6
05-17 11:13:22.799: V/PlayerDriver(2394): release string is 2.2 len 3
05-17 11:13:25.327: I/AudioHardwareALSA(2394): Output standby called!!. Turn off PCM device.
05-17 11:13:27.945: W/PowerManagerService(2487): Timer 0x7->0x3|0x1
05-17 11:13:27.945: I/PowerManagerService(2487): Ulight 7->3|0
05-17 11:13:32.051: W/ActivityManager(2487): Launch timeout has expired, giving up wake lock!
05-17 11:13:32.104: W/ActivityManager(2487): Activity idle timeout for HistoryRecord{4836f658 com.teluguone.torilt/.TORiLTActivity}
05-17 11:13:37.151: W/ActivityManager(2487): Activity destroy timeout

有人可以帮忙吗?

0 个答案:

没有答案