blob: 974b12babd0a73f8f9c1ec078533e19808c446e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package de.danoeh.antennapod.adapter.actionbutton;
import android.content.Context;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
public class PlayActionButton extends ItemActionButton {
public PlayActionButton(FeedItem item) {
super(item);
}
@Override
@StringRes
public int getLabel() {
return R.string.play_label;
}
@Override
@DrawableRes
public int getDrawable() {
return R.drawable.ic_play_24dp;
}
@Override
public void onClick(Context context) {
FeedMedia media = item.getMedia();
if (media == null) {
return;
}
if (!media.fileExists()) {
DBTasks.notifyMissingFeedMediaFile(context, media);
return;
}
new PlaybackServiceStarter(context, media)
.callEvenIfRunning(true)
.startWhenPrepared(true)
.shouldStream(false)
.start();
if (media.getMediaType() == MediaType.VIDEO) {
context.startActivity(PlaybackService.getPlayerActivityIntent(context, media));
}
}
}
|