コード例 #1
0
  @Override
  public void onCreate() {
    super.onCreate();

    // initialize default output device
    if (!BASS.BASS_Init(-1, 44100, 0)) {
      return;
    }

    // look for plugins
    plugins = "";
    String path = getApplicationInfo().nativeLibraryDir;
    String[] list = new File(path).list();
    for (String s : list) {
      int plug = BASS.BASS_PluginLoad(path + "/" + s, 0);
      if (plug != 0) { // plugin loaded...
        plugins += s + "\n"; // add it to the list
      }
    }
    if (plugins.equals("")) plugins = "no plugins - visit the BASS webpage to get some\n";
    if (activity != null) {
      activity.onPluginsLoaded(plugins);
    }
    BASS.BASS_SetConfig(BASS.BASS_CONFIG_BUFFER, 1000);
    Log.w("BASS.BASS_CONFIG_BUFFER", "" + BASS.BASS_GetConfig(BASS.BASS_CONFIG_BUFFER));
    // screen
    screenHeight =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getInt("screenHeight", 1000);
    screenWidth =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getInt("screenWidth", 800);

    // Pending Intend
    Intent intent = new Intent(this, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    pendIntent = PendingIntent.getActivity(this, 0, intent, 0);

    // tracklist
    updateTrackList();

    tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    tm.listen(telephone, PhoneStateListener.LISTEN_CALL_STATE);
    myBroadcastReceiver = new MyBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
    intentFilter.addAction("android.media.VOLUME_CHANGED_ACTION");
    intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    registerReceiver(myBroadcastReceiver, intentFilter);

    mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
    mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
    ComponentName rcvMedia = new ComponentName(getPackageName(), RcvMediaControl.class.getName());
    mAudioManager.registerMediaButtonEventReceiver(rcvMedia);

    // Use the remote control APIs (if available) to set the playback state
    if (Build.VERSION.SDK_INT >= 14 && remoteControlClient == null) {
      registerRemoteControl(rcvMedia);
    }
  }
コード例 #2
0
 // Set Activity
 public void setActivity(InterfacePlayer activity) {
   this.activity = activity;
   if (activity != null) {
     activity.onPluginsLoaded(plugins);
     activity.onFileLoaded(null, duration, "", "", 0, 0);
     activity.onProgressChanged(progress);
   }
 }