2017-03-09 04:42:40 -03:00
|
|
|
package org.schabi.newpipe;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
2017-09-03 03:04:18 -03:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2017-03-09 04:42:40 -03:00
|
|
|
import org.schabi.newpipe.player.PopupVideoPlayer;
|
2017-04-09 14:34:00 -03:00
|
|
|
import org.schabi.newpipe.util.Constants;
|
2017-03-09 04:42:40 -03:00
|
|
|
import org.schabi.newpipe.util.PermissionHelper;
|
|
|
|
|
|
|
|
/**
|
2017-06-05 16:33:01 -03:00
|
|
|
* Get the url from the intent and open a popup player
|
2017-03-09 04:42:40 -03:00
|
|
|
*/
|
2017-06-05 16:33:01 -03:00
|
|
|
public class RouterPopupActivity extends RouterActivity {
|
2017-03-09 04:42:40 -03:00
|
|
|
|
|
|
|
@Override
|
2017-06-05 16:33:01 -03:00
|
|
|
protected void handleUrl(String url) {
|
2017-04-09 14:34:00 -03:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
|
|
|
&& !PermissionHelper.checkSystemAlertWindowPermission(this)) {
|
|
|
|
Toast.makeText(this, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
2017-09-03 03:04:18 -03:00
|
|
|
StreamingService service;
|
|
|
|
try {
|
|
|
|
service = NewPipe.getServiceByUrl(url);
|
|
|
|
} catch (ExtractionException e) {
|
2017-04-09 14:34:00 -03:00
|
|
|
Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Intent callIntent = new Intent(this, PopupVideoPlayer.class);
|
2017-06-05 16:33:01 -03:00
|
|
|
switch (service.getLinkTypeByUrl(url)) {
|
2017-04-09 14:34:00 -03:00
|
|
|
case STREAM:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Toast.makeText(this, R.string.url_not_supported_toast, Toast.LENGTH_LONG).show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-05 16:33:01 -03:00
|
|
|
callIntent.putExtra(Constants.KEY_URL, url);
|
2017-04-09 14:34:00 -03:00
|
|
|
callIntent.putExtra(Constants.KEY_SERVICE_ID, service.getServiceId());
|
|
|
|
startService(callIntent);
|
2017-09-03 03:04:18 -03:00
|
|
|
|
|
|
|
finish();
|
2017-04-09 14:34:00 -03:00
|
|
|
}
|
2017-03-09 04:42:40 -03:00
|
|
|
}
|