control media playback
This commit is contained in:
parent
88f4d65b19
commit
71adc83b39
@ -2,6 +2,7 @@ package com.jens.automation2;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -318,6 +319,8 @@ public class Action
|
|||||||
}
|
}
|
||||||
else if(this.getAction().equals(Action_Enum.controlMediaPlayback))
|
else if(this.getAction().equals(Action_Enum.controlMediaPlayback))
|
||||||
{
|
{
|
||||||
|
returnString.append(": ");
|
||||||
|
|
||||||
switch (this.getParameter2())
|
switch (this.getParameter2())
|
||||||
{
|
{
|
||||||
case "0":
|
case "0":
|
||||||
@ -335,6 +338,8 @@ public class Action
|
|||||||
case "4":
|
case "4":
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.next));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.next));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (parameter2 != null && parameter2.length() > 0)
|
else if (parameter2 != null && parameter2.length() > 0)
|
||||||
@ -501,6 +506,9 @@ public class Action
|
|||||||
case playMusic:
|
case playMusic:
|
||||||
Actions.playMusic(this.getParameter1(), toggleActionIfPossible);
|
Actions.playMusic(this.getParameter1(), toggleActionIfPossible);
|
||||||
break;
|
break;
|
||||||
|
case controlMediaPlayback:
|
||||||
|
Actions.controlMediaPlayback(context, Integer.parseInt(getParameter2()));
|
||||||
|
break;
|
||||||
case sendTextMessage:
|
case sendTextMessage:
|
||||||
Actions.sendTextMessage(context, this.getParameter2().split(Actions.smsSeparator));
|
Actions.sendTextMessage(context, this.getParameter2().split(Actions.smsSeparator));
|
||||||
break;
|
break;
|
||||||
@ -517,7 +525,10 @@ public class Action
|
|||||||
Actions.createNotification(this);
|
Actions.createNotification(this);
|
||||||
break;
|
break;
|
||||||
case closeNotification:
|
case closeNotification:
|
||||||
|
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M)
|
||||||
Actions.closeNotification(this);
|
Actions.closeNotification(this);
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("w", "Close notification", "Close notification was requested, but OS version is too low: " + String.valueOf(Build.VERSION.SDK_INT), 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||||
|
@ -1472,32 +1472,42 @@ public class Actions
|
|||||||
{
|
{
|
||||||
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
|
||||||
if (mAudioManager.isMusicActive()) {
|
if (mAudioManager.isMusicActive())
|
||||||
|
{
|
||||||
|
|
||||||
Intent.CATEGORY_APP_MUSIC
|
// Intent.CATEGORY_APP_MUSIC
|
||||||
Intent i = new Intent("com.android.music.musicservicecommand");
|
Intent i = new Intent("com.android.music.musicservicecommand");
|
||||||
|
|
||||||
i.putExtra("command", "pause");
|
|
||||||
|
|
||||||
switch(command)
|
switch(command)
|
||||||
{
|
{
|
||||||
public static final String SERVICECMD = "com.android.music.musicservicecommand";
|
// public static final String SERVICECMD = "com.android.music.musicservicecommand";
|
||||||
public static final String CMDNAME = "command";
|
|
||||||
|
|
||||||
public static final String CMDSTOP = "stop";
|
// public static final String CMDSTOP = "stop";
|
||||||
public static final String CMDPAUSE = "pause";
|
// public static final String CMDPAUSE = "pause";
|
||||||
public static final String CMDPREVIOUS = "previous";
|
|
||||||
public static final String CMDNEXT = "next";
|
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
i.putExtra("command", "togglepause");
|
i.putExtra("command", "togglepause");
|
||||||
break;
|
break;
|
||||||
|
case 1:
|
||||||
|
i.putExtra("command", "play");
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
i.putExtra("command", "pause");
|
i.putExtra("command", "pause");
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
i.putExtra("command", "previous");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
i.putExtra("command", "next");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
context.this.sendBroadcast(i);
|
|
||||||
|
AutomationService.getInstance().sendBroadcast(i);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTransactionCode()
|
private String getTransactionCode()
|
||||||
|
Loading…
Reference in New Issue
Block a user