mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Check network connection type before choosing the default bitrate
This commit is contained in:
parent
bb9b2d95b5
commit
695f406bd6
1 changed files with 21 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package com.cappielloantonio.play.util;
|
package com.cappielloantonio.play.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
@ -30,8 +32,8 @@ public class MusicUtil {
|
||||||
"&v=" + params.get("v") +
|
"&v=" + params.get("v") +
|
||||||
"&c=" + params.get("c") +
|
"&c=" + params.get("c") +
|
||||||
"&id=" + song.getId() +
|
"&id=" + song.getId() +
|
||||||
"&maxBitRate=" + PreferenceUtil.getInstance(context).getMaxBitrateWifi() +
|
"&maxBitRate=" + getBitratePreference(context) +
|
||||||
"&format=" + PreferenceUtil.getInstance(context).getAudioTranscodeFormat();
|
"&format=" + getFormatPreference(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MediaItem getSongDownloadItem(Song song) {
|
public static MediaItem getSongDownloadItem(Song song) {
|
||||||
|
|
@ -128,4 +130,21 @@ public class MusicUtil {
|
||||||
return R.drawable.default_album_art;
|
return R.drawable.default_album_art;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getBitratePreference(Context context) {
|
||||||
|
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
switch (connectivityManager.getActiveNetworkInfo().getType()) {
|
||||||
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
|
return PreferenceUtil.getInstance(context).getMaxBitrateWifi();
|
||||||
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
|
return PreferenceUtil.getInstance(context).getMaxBitrateMobile();
|
||||||
|
default:
|
||||||
|
return PreferenceUtil.getInstance(context).getMaxBitrateWifi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getFormatPreference(Context context) {
|
||||||
|
return PreferenceUtil.getInstance(context).getAudioTranscodeFormat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue