Settings.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2015 Bilibili
  3. * Copyright (C) 2015 Zhang Rui <bbcallen@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.edufound.mobile.ijkplayer.application;
  18. import android.content.Context;
  19. import android.content.SharedPreferences;
  20. import android.preference.PreferenceManager;
  21. import com.edufound.mobile.R;
  22. public class Settings {
  23. private Context mAppContext;
  24. private SharedPreferences mSharedPreferences;
  25. public static final int PV_PLAYER__AndroidMediaPlayer = 1;
  26. public static final int PV_PLAYER__IjkMediaPlayer = 2;
  27. public static final int PV_PLAYER__IjkExoMediaPlayer = 3;
  28. public Settings(Context context) {
  29. mAppContext = context.getApplicationContext();
  30. mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext);
  31. }
  32. public boolean getEnableBackgroundPlay() {
  33. String key = mAppContext.getString(R.string.pref_key_enable_background_play);
  34. return mSharedPreferences.getBoolean(key, false);
  35. }
  36. public int getPlayer() {
  37. String key = mAppContext.getString(R.string.pref_key_player);
  38. String value = mSharedPreferences.getString(key, "");
  39. try {
  40. return Integer.valueOf(value).intValue();
  41. } catch (NumberFormatException e) {
  42. return 0;
  43. }
  44. }
  45. public boolean getUsingMediaCodec() {
  46. String key = mAppContext.getString(R.string.pref_key_using_media_codec);
  47. return mSharedPreferences.getBoolean(key, false);
  48. }
  49. public boolean getUsingMediaCodecAutoRotate() {
  50. String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate);
  51. return mSharedPreferences.getBoolean(key, false);
  52. }
  53. public boolean getMediaCodecHandleResolutionChange() {
  54. String key = mAppContext.getString(R.string.pref_key_media_codec_handle_resolution_change);
  55. return mSharedPreferences.getBoolean(key, false);
  56. }
  57. public boolean getUsingOpenSLES() {
  58. String key = mAppContext.getString(R.string.pref_key_using_opensl_es);
  59. return mSharedPreferences.getBoolean(key, false);
  60. }
  61. public String getPixelFormat() {
  62. String key = mAppContext.getString(R.string.pref_key_pixel_format);
  63. return mSharedPreferences.getString(key, "");
  64. }
  65. public boolean getEnableNoView() {
  66. String key = mAppContext.getString(R.string.pref_key_enable_no_view);
  67. return mSharedPreferences.getBoolean(key, false);
  68. }
  69. public boolean getEnableSurfaceView() {
  70. String key = mAppContext.getString(R.string.pref_key_enable_surface_view);
  71. return mSharedPreferences.getBoolean(key, false);
  72. }
  73. public boolean getEnableTextureView() {
  74. String key = mAppContext.getString(R.string.pref_key_enable_texture_view);
  75. return mSharedPreferences.getBoolean(key, false);
  76. }
  77. public boolean getEnableDetachedSurfaceTextureView() {
  78. String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture);
  79. return mSharedPreferences.getBoolean(key, false);
  80. }
  81. public boolean getUsingMediaDataSource() {
  82. String key = mAppContext.getString(R.string.pref_key_using_mediadatasource);
  83. return mSharedPreferences.getBoolean(key, false);
  84. }
  85. }