Android source code: a multifunctional player that integrates novels, music and movies

Android source code: a multifunctional player that integrates novels, music and movies

Functional classification: Audio and video

Supported platforms: Android

Operating environment: Android

Development language: Java

Development tool: Eclipse

Source code size: 8.54MB

Source code download address: http://down..com/data/1976551

Source code introduction

An all-in-one player suitable for beginners to learn.

Source code running screenshot

Run screenshot

Run screenshot

Run screenshot

Run screenshot

Run screenshot

Run screenshot

Source code snippet

  1. public   class Main extends Activity implements OnClickListener{
  2. private Button btn1,btn2,btn3;
  3. private   boolean isExit;
  4. private SharedPreferences sp;
  5. private Editor et;
  6. private FrameLayout fldetails;
  7. private Set<string> ePathSet;
  8. private Set<string> vPathSet;
  9. private Set<string> mPathSet;
  10.       
  11. @Override  
  12. protected   void onCreate(Bundle savedInstanceState) {
  13. super .onCreate(savedInstanceState);
  14. requestWindowFeature(Window.FEATURE_NO_TITLE);
  15. setContentView(R.layout.main);
  16.           
  17. sp = getSharedPreferences(Tool.SP_MYSHAREDPREFERENCES, MODE_PRIVATE);
  18. et = sp.edit();
  19. ePathSet = new HashSet<string>();
  20. vPathSet = new HashSet<string>();
  21. mPathSet = new HashSet<string>();
  22. init();
  23. Tool.logd( "★★★★★" +sp.getBoolean(Tool.SP_ISINITPATH, false ));
  24. fldetails = (FrameLayout) findViewById(R.id.flDetails);
  25. btn1 = (Button) findViewById(R.id.btn1);
  26. btn2 = (Button) findViewById(R.id.btn2);
  27. btn3 = (Button) findViewById(R.id.btn3);
  28. btn1.setOnClickListener( this );
  29. btn2.setOnClickListener( this );
  30. btn3.setOnClickListener( this );
  31.           
  32. FragmentTransaction ft = getFragmentManager().beginTransaction();
  33. EbookFragment ebook = new EbookFragment();
  34. ft.replace(R.id.flDetails, ebook);
  35. ft.commit();
  36. fldetails.setBackgroundResource(R.drawable.ebook_bg);
  37. }
  38.   
  39. private   void init() {
  40. // TODO Auto-generated method stub  
  41. boolean isInitPath = sp.getBoolean(Tool.SP_ISINITPATH, false );
  42. if (!isInitPath){
  43. String[] e_paths = Tool.getPathByXml( this , Tool.EBOOK);
  44. String[] v_paths = Tool.getPathByXml( this , Tool.VIDEO);
  45. String[] m_paths = Tool.getPathByXml( this , Tool.MUSIC);
  46. for (String path : e_paths){
  47. ePathSet.add(path);
  48. }
  49. for (String path : v_paths){
  50. vPathSet.add(path);
  51. }
  52. for (String path : m_paths){
  53. mPathSet.add(path);
  54. }
  55. et.putStringSet( "ebook_path" , ePathSet);
  56. et.putStringSet( "video_path" , vPathSet);
  57. et.putStringSet( "music_path" , mPathSet);
  58. et.putBoolean( "isInitPath" , true );
  59. et.commit();
  60. }
  61.           
  62. }
  63.   
  64. @Override  
  65. public   boolean onCreateOptionsMenu(Menu menu) {
  66. // Inflate the menu; this adds items to the action bar if it is present.  
  67. setIconEnable(menu, true );
  68. getMenuInflater().inflate(R.menu.main, menu);
  69. return   true ;
  70. }
  71.   
  72. private   void setIconEnable(Menu menu, boolean b) {
  73. // TODO Auto-generated method stub  
  74. try {
  75. Class<!--?--> clazz = Class.forName( "com.android.internal.view.menu.MenuBuilder" );
  76. Method m = clazz.getDeclaredMethod( "setOptionalIconsVisible" , boolean . class );
  77. m.setAccessible( true );
  78. m.invoke(menu, b);
  79. } catch (Exception e) {
  80. e.printStackTrace();
  81. }
  82. }
  83.   
  84. @Override  
  85. public   boolean onOptionsItemSelected(MenuItem item) {
  86. // TODO Auto-generated method stub  
  87. super .onOptionsItemSelected(item);
  88. switch (item.getItemId()){
  89. case R.id.add_ebook:
  90. et.putInt(Tool.SP_TYPE, Tool.EBOOK);
  91. et.commit();
  92. Intent intent = new Intent(Main. this ,AddingPath. class );
  93. startActivity(intent);
  94. overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
  95. break ;
  96. case R.id.add_video:
  97. et.putInt(Tool.SP_TYPE, Tool.VIDEO);
  98. et.commit();
  99. Intent intent1 = new Intent(Main. this ,AddingPath. class );
  100. startActivity(intent1);
  101. overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
  102. break ;
  103. case R.id.add_music:
  104. et.putInt(Tool.SP_TYPE, Tool.MUSIC);
  105. Intent intent2 = new Intent(Main. this ,AddingPath. class );
  106. startActivity(intent2);
  107. et.commit();
  108. break ;
  109. case R.id.setting:
  110. Intent intent3 = new Intent(Main. this ,PreferenceSetting. class );
  111. startActivity(intent3);
  112. break ;
  113. case R.id.baidu:
  114. Uri uri = Uri.parse( "http://www.baidu.com" );
  115. Intent intent4 = new Intent(Intent.ACTION_VIEW,uri);
  116. startActivity(intent4);
  117. break ;
  118. case R.id.about:
  119. showAuthorDetail();
  120. break ;
  121. case R.id.exit:
  122. System.exit( 0 );
  123. break ;
  124. }
  125. return   true ;
  126. }
  127.   
  128. private   void showAuthorDetail() {
  129. // TODO Auto-generated method stub  
  130. Builder bd = new Builder( this );
  131. bd.setTitle( "About Us" );
  132. bd.setMessage( "Version: 1.0 \nDeveloper: Yuan Ye \nDevelopment time: 2014-05-16" );
  133. bd.show();
  134. }
  135.   
  136. @Override  
  137. public   void onClick(View v) {
  138. FragmentTransaction ft = getFragmentManager().beginTransaction();
  139. switch (v.getId()){
  140. case R.id.btn1:
  141. EbookFragment ebook = new EbookFragment();
  142. ft.replace(R.id.flDetails, ebook);
  143. ft.commit();
  144. fldetails.setBackgroundResource(R.drawable.ebook_bg);
  145. break ;
  146. case R.id.btn2:
  147. VideoFragment video = new VideoFragment();
  148. ft.replace(R.id.flDetails,video);
  149. ft.commit();
  150. fldetails.setBackgroundResource(R.drawable.movie_bg);
  151. break ;
  152. case R.id.btn3:
  153. MusicFragment music = new MusicFragment();
  154. ft.replace(R.id.flDetails, music);
  155. ft.commit();
  156. fldetails.setBackgroundResource(R.drawable.music_bg1);
  157. break ;
  158. }
  159. }
  160.       
  161. @Override  
  162. public   boolean onKeyDown( int keyCode, KeyEvent event) {
  163.           
  164. if (keyCode == KeyEvent.KEYCODE_BACK)
  165. {
  166. exitBy2Click(); //Call the double-click exit function  
  167. }
  168. return   false ;
  169. }
  170.       
  171. private   void exitBy2Click() {
  172. Timer tExit = null ;
  173. if (isExit == false ) {
  174. isExit = true ; // Prepare to exit  
  175. Toast.makeText( this , "Press again to exit the program" , Toast.LENGTH_SHORT).show();
  176. tExit = new Timer();
  177. tExit.schedule( new TimerTask() {
  178. @Override   
  179. public   void run() {
  180. isExit = false ; // Cancel exit  
  181. }
  182. }, 2000 ); // If the return key is not pressed within 2 seconds, start the timer to cancel the task just executed  
  183.               
  184. } else {
  185. finish();
  186. }
  187. }
  188.   
  189. }</string></string></string></string></string></string>

Source code download address: http://down..com/data/1976551

<<:  Android source code download: Bluetooth online Gobang game

>>:  What exactly is Google's Ara project?

Recommend

Will there be a winner in the ongoing battle between Xiaomi and LeTV?

Among the major Internet companies, the "gru...

Should community O2O bypass property management?

On the one hand, the media is constantly promotin...

New media operations: 8 ways to follow hot topics

The author of this article provides 8 ways (ideas...

As a new app, you can't miss these free resources

For a new app, you may hope to get some market re...

Are we really helpless in the face of poplar catkins?

In Beijing in spring, there are often two kinds o...

Why do we get more and more addicted to celebrity gossip?

At the beginning of the new year, eye-catching &q...

The most comprehensive iOS language learning materials collection

This learning material is prepared for iOS beginn...

“Riding on the popularity” doesn’t work anymore? No, it was ruined!

At the beginning of the article, we are going to ...