I have work on one Android app. The usual concept of this application is to play a song on multiple devices at the same time. Everything is done, but Song does not play in Sync.I did a lot of R & d to solve this problem, but did not succeed. But in the end I found one release of Android Media Player. To find this problem, I have one demo application called Application.Description.
Demo Application Description
I create two objects of the Android Android player firstPlayer and secondPlayer.firstPlayer. The game will begin immediately after the application is Lunch.now. I have one button in test.xml.once. The user clicks on this button. The second player will start and play the same music that I installed in firstPlayer.and I am also looking for SecondPlayer in the position where firstPlayer is Play.
the code
changePlayer = (Button) findViewById(R.id.changePlayer);
String fileName = "/qq.mp3";
String baseDir = Environment.getExternalStorageDirectory() + "/Test App" + fileName;
Log.e(TAG, "path :" + baseDir);
try {
firstPlayer = new MediaPlayer();
secondPlayer = new MediaPlayer();
firstPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
secondPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
firstPlayer.setDataSource(baseDir);
secondPlayer.setDataSource(baseDir);
firstPlayer.prepare();
secondPlayer.prepare();
firstPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
changePlayer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!secondPlayer.isPlaying()) {
Log.e(TAG, "Media Player Start M2");
secondPlayer.start();
}
int sek = firstPlayer.getCurrentPosition();
secondPlayer.seekTo(firstPlayer.getCurrentPosition());
Log.e(TAG, "Current Playe Time ::" + secondPlayer.getCurrentPosition());
Log.e(TAG, "First Playe Time ::" + sek);
Log.e(TAG, "firstPlayer Playe Time ::" + firstPlayer.getCurrentPosition());
Log.e(TAG, "secondPlayer Playe Time ::" + secondPlayer.getCurrentPosition());
}
});
Problem
- I get one strange problem, since the media player does not play in Sync, it has a slightly different song to play. If I am looking for secondPlayer where firstPlayer is played and then it plays in Sync, but this is not like the player playing in different ways .
Note
- , , . ExoPlayer, VlcPlayer, UniversalPlayer , .
.
, Luck.I 100% . Seedio IOS.I IOS, IOS . 100% .
, , - .
, .