mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-29 13:17:43 +00:00
Added rewind and fast-forward buttons to MPRIS controls
This commit is contained in:
parent
6471bafdd9
commit
2f26fa5188
@ -187,6 +187,36 @@ public class MprisActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.rew_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
BackgroundService.RunCommand(MprisActivity.this, new BackgroundService.InstanceCallback() {
|
||||
@Override
|
||||
public void onServiceStart(BackgroundService service) {
|
||||
Device device = service.getDevice(deviceId);
|
||||
MprisPlugin mpris = (MprisPlugin)device.getPlugin("plugin_mpris");
|
||||
if (mpris == null) return;
|
||||
mpris.Seek(-10000000); // -10 seconds. TODO: plugin settings UI?
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.ff_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
BackgroundService.RunCommand(MprisActivity.this, new BackgroundService.InstanceCallback() {
|
||||
@Override
|
||||
public void onServiceStart(BackgroundService service) {
|
||||
Device device = service.getDevice(deviceId);
|
||||
MprisPlugin mpris = (MprisPlugin)device.getPlugin("plugin_mpris");
|
||||
if (mpris == null) return;
|
||||
mpris.Seek(10000000); // 10 seconds. TODO: plugin settings UI?
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.next_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -84,6 +84,13 @@ public class MprisPlugin extends Plugin {
|
||||
device.sendPackage(np);
|
||||
}
|
||||
|
||||
public void Seek(int offset) {
|
||||
NetworkPackage np = new NetworkPackage(NetworkPackage.PACKAGE_TYPE_MPRIS);
|
||||
np.set("player",player);
|
||||
np.set("Seek",offset);
|
||||
device.sendPackage(np);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPackageReceived(NetworkPackage np) {
|
||||
if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_MPRIS)) return false;
|
||||
|
@ -37,7 +37,7 @@
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="200dip"
|
||||
android:layout_height="70dip"
|
||||
android:layout_height="50dip"
|
||||
android:layout_gravity="center"
|
||||
>
|
||||
|
||||
@ -45,19 +45,36 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/prev_button"
|
||||
android:src="@android:drawable/ic_media_rew"
|
||||
android:src="@android:drawable/ic_media_previous"
|
||||
android:contentDescription="@string/mpris_previous"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_weight="0.25"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/rew_button"
|
||||
android:src="@android:drawable/ic_media_rew"
|
||||
android:contentDescription="@string/mpris_rew"
|
||||
android:layout_weight="0.25"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/ff_button"
|
||||
android:src="@android:drawable/ic_media_ff"
|
||||
android:contentDescription="@string/mpris_ff"
|
||||
android:layout_weight="0.25"
|
||||
/>
|
||||
|
||||
<ImageButton
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/next_button"
|
||||
android:src="@android:drawable/ic_media_ff"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/ic_media_next"
|
||||
android:contentDescription="@string/mpris_next"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_weight="0.25"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -50,6 +50,8 @@
|
||||
<string name="settings">KDE Connect Settings</string>
|
||||
<string name="mpris_play">Play</string>
|
||||
<string name="mpris_previous">Previous</string>
|
||||
<string name="mpris_rew">Rewind</string>
|
||||
<string name="mpris_ff">Fast-forward</string>
|
||||
<string name="mpris_next">Next</string>
|
||||
<string name="mpris_volume">Volume</string>
|
||||
<string name="share_to">Share To...</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user