Video quality selection setting feature added

This commit is contained in:
subhadipThinkpad 2019-01-07 02:43:25 +05:30
parent 5bbcd8c3bf
commit 5dfa88b506
4 changed files with 55 additions and 4 deletions

View File

@ -93,6 +93,13 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
preference.setSummary(stringValue);
return true;
}
//check if video quality has changed & provide selected quality
else if (preference.getKey().equals("pref_quality")) {
Toast.makeText(preference.getContext(), "Quality changed", Toast.LENGTH_LONG).show();
preference.setSummary(stringValue);
return true;
}
preference.setSummary(stringValue);
@ -201,6 +208,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
// guidelines.
bindPreferenceSummaryToValue(findPreference("pref_api_base"));
bindPreferenceSummaryToValue(findPreference("pref_theme"));
bindPreferenceSummaryToValue(findPreference("pref_quality"));
}
@Override

View File

@ -202,11 +202,34 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
assert videoMetaDataFragment != null;
videoMetaDataFragment.updateVideoMeta(video, mService);
Log.v(TAG, "url : " + video.getFiles().get(0).getFileUrl());
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
String videoQuality = sharedPref.getString("pref_quality", "");
//get video quality
if (video.getFiles().size() > 1 && videoQuality.equals("High")) {
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
Log.v(TAG, "urlHigh : " + video.getFiles().get(0).getFileUrl());
} else if (video.getFiles().size() >= 2 && videoQuality.equals("Medium")) {
mService.setCurrentStreamUrl(video.getFiles().get(1).getFileUrl());
Log.v(TAG, "urlMed : " + video.getFiles().get(1).getFileUrl());
} else if (video.getFiles().size() >= 3 && videoQuality.equals("Low")) {
mService.setCurrentStreamUrl(video.getFiles().get(2).getFileUrl());
Log.v(TAG, "urlLow : " + video.getFiles().get(2).getFileUrl());
} else {
//default quality
mService.setCurrentStreamUrl(video.getFiles().get(0).getFileUrl());
Log.v(TAG, "url : " + video.getFiles().get(0).getFileUrl());
}
// Log.v(TAG, "url : " + video.getFiles().size());
if (sharedPref.getBoolean("pref_torrent_player", false)) {
String stream = video.getFiles().get(0).getTorrentUrl();

View File

@ -435,4 +435,16 @@
</string-array>
<string-array name="empty_array"/>
<string-array name="quality">
<item>Low</item>
<item>Medium</item>
<item>High</item>
</string-array>
<string-array name="qualityValues">
<item>Low</item>
<item>Medium</item>
<item>High</item>
</string-array>
</resources>

View File

@ -30,6 +30,14 @@
android:summary="@string/pref_description_language"
android:title="@string/pref_language" />
<ListPreference
android:defaultValue="High"
android:entries="@array/quality"
android:entryValues="@array/qualityValues"
android:key="pref_quality"
android:summary="Select Video quality"
android:title="Video Quality"/>
<ListPreference
android:title="@string/pref_title_app_theme"
android:summary="@string/pref_description_app_theme"