-
-
Save codingwithsara/4e4f8df688e55f969b7047fd5ed06c12 to your computer and use it in GitHub Desktop.
Android MusicPlayer 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private Button playBtn; | |
private SeekBar positionBar; | |
private SeekBar volumeBar; | |
private TextView elapsedTimeLabel; | |
private TextView remainingTimeLabel; | |
private MediaPlayer mp; | |
private int totalTime; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
playBtn = findViewById(R.id.playBtn); | |
elapsedTimeLabel = findViewById(R.id.elapsedTimeLabel); | |
remainingTimeLabel = findViewById(R.id.remainingTimeLabel); | |
// Media Playerの初期化 | |
mp = MediaPlayer.create(this, R.raw.music); | |
mp.setLooping(true); | |
mp.seekTo(0); | |
mp.setVolume(0.5f, 0.5f); | |
totalTime = mp.getDuration(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment