Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1001271 // androidPlayMp3

JavaX fragment (include)

import android.app.*;
import android.media.*;
import android.net.*;

// do not call in ui thread.
// waits until playback done.

static void androidPlayMp3(Activity androidContext, File mp3) {
  final MediaPlayer mPlayer = MediaPlayer.create(androidContext, Uri.fromFile(mp3));
  
  final new Flag done;
  mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
    public void onCompletion(MediaPlayer mp) {
      mPlayer.release();
      done.raise();
    }
  });

  mPlayer.start();
  done.waitUntilUp();
}

Author comment

Began life as a copy of #1001270

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001271
Snippet name: androidPlayMp3
Eternal ID of this version: #1001271/1
Text MD5: bfe77de2836f623f2d741034b3363646
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-05-07 13:50:46
Source code size: 546 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 654 / 956
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)