mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
added white play button icon for notification controls; pause button soon to follow.
Some checks for audioStreams being null added, along with minor semnatic restructuring of parseDashManifest()
This commit is contained in:
parent
f2e761c07c
commit
25c5f95ad9
@ -120,6 +120,9 @@ class ActionBarHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "FAILED to set audioStream value!");
|
||||
}
|
||||
}
|
||||
|
||||
private void selectFormatItem(int i) {
|
||||
@ -301,6 +304,8 @@ class ActionBarHandler {
|
||||
intent = new Intent(activity, BackgroundPlayer.class);
|
||||
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
Log.i(TAG, "audioStream is null:" + (audioStream == null));
|
||||
Log.i(TAG, "audioStream.url is null:"+(audioStream.url==null));
|
||||
intent.setDataAndType(Uri.parse(audioStream.url),
|
||||
MediaFormat.getMimeById(audioStream.format));
|
||||
intent.putExtra(Intent.EXTRA_TITLE, videoTitle);
|
||||
|
@ -45,8 +45,6 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||
private static final String TAG = BackgroundPlayer.class.toString();
|
||||
private static final String ACTION_STOP = TAG+".STOP";
|
||||
private static final String ACTION_PLAYPAUSE = TAG+".PLAYPAUSE";
|
||||
//private Looper mServiceLooper;
|
||||
//private ServiceHandler mServiceHandler;
|
||||
|
||||
public BackgroundPlayer() {
|
||||
super();
|
||||
@ -138,29 +136,23 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||
wifiLock.acquire();
|
||||
mediaPlayer.start();
|
||||
|
||||
//mediaPlayer.getCurrentPosition()
|
||||
int vidLength = mediaPlayer.getDuration();
|
||||
|
||||
//Intent genericIntent = new Intent(owner, owner.getClass());
|
||||
|
||||
//PendingIntent playPI = PendingIntent.getService(owner, noteID, genericIntent, 0);
|
||||
PendingIntent playPI = PendingIntent.getBroadcast(owner, noteID, new Intent(ACTION_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
NotificationCompat.Action.Builder buttonBuilder =
|
||||
new NotificationCompat.Action.Builder(R.drawable.ic_play_arrow_black,
|
||||
"Play", playPI);//todo:translatable string
|
||||
NotificationCompat.Action playButton = buttonBuilder.build();
|
||||
|
||||
PendingIntent stopPI = PendingIntent.getBroadcast(owner, noteID,
|
||||
new Intent(ACTION_STOP), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(Integer.MAX_VALUE);
|
||||
filter.addAction(ACTION_PLAYPAUSE);
|
||||
filter.addAction(ACTION_STOP);
|
||||
registerReceiver(broadcastReceiver, filter);
|
||||
|
||||
//playPauseButton
|
||||
PendingIntent playPI = PendingIntent.getBroadcast(owner, noteID, new Intent(ACTION_PLAYPAUSE), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
NotificationCompat.Action playButton = new NotificationCompat.Action.Builder
|
||||
(R.drawable.ic_play_arrow_white_48dp, "Play", playPI).build();
|
||||
|
||||
NotificationCompat.Action pauseButton = new NotificationCompat.Action.Builder
|
||||
(R.drawable.ic_play_arrow_white_48dp, "Pause", playPI).build();
|
||||
|
||||
PendingIntent stopPI = PendingIntent.getBroadcast(owner, noteID,
|
||||
new Intent(ACTION_STOP), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
//todo: make it so that tapping the notification brings you back to the Video's DetailActivity
|
||||
//using setContentIntent
|
||||
noteBuilder = new NotificationCompat.Builder(owner);
|
||||
@ -232,7 +224,7 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare
|
||||
//noteBuilder.setProgress(0, 0, false);//remove progress bar
|
||||
noteMgr.cancel(noteID);//remove notification
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
mediaPlayer.release();//release system resources
|
||||
mediaPlayer.release();//release mediaPlayer's system resources
|
||||
|
||||
|
||||
wifiLock.release();//release wifilock
|
||||
|
@ -371,6 +371,16 @@ public class YoutubeVideoExtractor extends VideoExtractor {
|
||||
//todo: replace this with a call to getVideoId, if possible
|
||||
videoInfo.id = matchGroup1("v=([0-9a-zA-Z_-]{11})", pageUrl);
|
||||
|
||||
if(videoInfo.audioStreams == null
|
||||
|| videoInfo.audioStreams.length == 0) {
|
||||
Log.e(TAG, "uninitialised audio streams!");
|
||||
}
|
||||
|
||||
if(videoInfo.videoStreams == null
|
||||
|| videoInfo.videoStreams.length == 0) {
|
||||
Log.e(TAG, "uninitialised video streams!");
|
||||
}
|
||||
|
||||
videoInfo.age_limit = 0;
|
||||
|
||||
//average rating
|
||||
@ -445,13 +455,14 @@ public class YoutubeVideoExtractor extends VideoExtractor {
|
||||
try {
|
||||
XmlPullParser parser = Xml.newPullParser();
|
||||
parser.setInput(new StringReader(dashDoc));
|
||||
int eventType = parser.getEventType();
|
||||
String tagName = "";
|
||||
String currentMimeType = "";
|
||||
int currentBandwidth = -1;
|
||||
int currentSamplingRate = -1;
|
||||
boolean currentTagIsBaseUrl = false;
|
||||
while(eventType != XmlPullParser.END_DOCUMENT) {
|
||||
for(int eventType = parser.getEventType();
|
||||
eventType != XmlPullParser.END_DOCUMENT;
|
||||
eventType = parser.next() ) {
|
||||
switch(eventType) {
|
||||
case XmlPullParser.START_TAG:
|
||||
tagName = parser.getName();
|
||||
@ -465,8 +476,8 @@ public class YoutubeVideoExtractor extends VideoExtractor {
|
||||
} else if(tagName.equals("BaseURL")) {
|
||||
currentTagIsBaseUrl = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case XmlPullParser.TEXT:
|
||||
if(currentTagIsBaseUrl &&
|
||||
(currentMimeType.contains("audio"))) {
|
||||
@ -479,16 +490,14 @@ public class YoutubeVideoExtractor extends VideoExtractor {
|
||||
audioStreams.add(new VideoInfo.AudioStream(parser.getText(),
|
||||
format, currentBandwidth, currentSamplingRate));
|
||||
}
|
||||
//missing break here?
|
||||
case XmlPullParser.END_TAG:
|
||||
if(tagName.equals("AdaptationSet")) {
|
||||
currentMimeType = "";
|
||||
} else if(tagName.equals("BaseURL")) {
|
||||
currentTagIsBaseUrl = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}//no break needed here
|
||||
}
|
||||
eventType = parser.next();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -583,10 +592,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Context.exit();
|
||||
if(result != null)
|
||||
return result.toString();
|
||||
else
|
||||
return "";
|
||||
return (result == null ? "" : result.toString());
|
||||
}
|
||||
|
||||
private String cleanUrl(String complexUrl) {
|
||||
|
BIN
app/src/main/res/drawable-hdpi/ic_play_arrow_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_play_arrow_white_48dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 283 B |
BIN
app/src/main/res/drawable-mdpi/ic_play_arrow_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_play_arrow_white_48dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
BIN
app/src/main/res/drawable-xhdpi/ic_play_arrow_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_play_arrow_white_48dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_play_arrow_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_play_arrow_white_48dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 461 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_48dp.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_play_arrow_white_48dp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 605 B |
Loading…
Reference in New Issue
Block a user