diff --git a/app/src/main/java/org/ntlab/amaryllis/client/TestPlayActivity.java b/app/src/main/java/org/ntlab/amaryllis/client/TestPlayActivity.java new file mode 100644 index 0000000..70445b4 --- /dev/null +++ b/app/src/main/java/org/ntlab/amaryllis/client/TestPlayActivity.java @@ -0,0 +1,73 @@ +package org.ntlab.amaryllis.client; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.media.AudioManager; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.os.IBinder; +import android.os.RemoteException; +import android.support.v4.media.MediaBrowserCompat; +import android.support.v4.media.MediaMetadataCompat; +import android.support.v4.media.session.MediaControllerCompat; +import android.support.v4.media.session.PlaybackStateCompat; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import org.ntlab.amaryllis.client.entities.AmaryllisBackgroundService; +import org.ntlab.amaryllis.client.voiceservice.TestVoiceService; + +import java.io.IOException; +import java.util.List; + +public class TestPlayActivity extends AppCompatActivity { + MediaBrowserCompat mBrowser; + MediaControllerCompat mController; + Button button_play; + TextView textView_title; + TextView textView_position; + MediaPlayer mediaPlayer; + TestVoiceService myService; + Intent serviceIntent; + + ServiceConnection serviceConnection = new ServiceConnection(){ + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + myService = ((TestVoiceService.MyBinder)service).getService(); + //myService.setMessage("Hello, IBinder!"); + startService(serviceIntent); + } + + @Override + public void onServiceDisconnected(ComponentName name) { + + myService = null; + } + }; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_test_play); + + button_play=findViewById(R.id.button_play); + textView_title=findViewById(R.id.textView_title); + textView_position=findViewById(R.id.textView_position); + serviceIntent=new Intent( + getBaseContext(),TestVoiceService.class + ); + bindService(serviceIntent,serviceConnection, Context.BIND_AUTO_CREATE); + button_play.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + myService.play(); + } + }); + } +} \ No newline at end of file