Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package ru.timuruktus.fun;
  2.  
  3. import android.app.Activity;
  4. import android.media.MediaPlayer;
  5. import android.os.Bundle;
  6. import android.os.Environment;
  7. import android.util.Log;
  8. import android.view.SurfaceHolder;
  9. import android.view.SurfaceView;
  10. import android.view.View;
  11.  
  12. import java.io.File;
  13. import java.io.FileDescriptor;
  14. import java.io.FileInputStream;
  15. import java.io.IOException;
  16. import java.net.URL;
  17.  
  18.  
  19. public class MainActivity extends Activity implements View.OnClickListener {
  20.  
  21.     final String LOG_TAG = "myLogs";
  22.     SurfaceView videoView;
  23.     SurfaceHolder surfaceHolder;
  24.     DataBaseActions DBA;
  25.     public static final int LOAD_CITIES = 1;
  26.     MediaPlayer mp;
  27.  
  28.     public void onCreate(Bundle savedInstanceState) {
  29.         super.onCreate(savedInstanceState);
  30.         setContentView(R.layout.main);
  31.  
  32.         DBA = new DataBaseActions(LOAD_CITIES);
  33.         videoView = (SurfaceView) findViewById(R.id.videoView);
  34.         mp = new MediaPlayer();
  35.         mp.reset();
  36.  
  37.         try {
  38.             File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
  39.             File file = new File(path, "490527.mp4");
  40.             mp.setDataSource(file.toString());
  41.             mp.prepare();
  42.             surfaceHolder = videoView.getHolder();
  43.             mp.setDisplay(surfaceHolder);
  44.         } catch (Exception ex) {
  45.             Log.d(LOG_TAG, "Error in reading the welcome file");
  46.             ex.printStackTrace();
  47.         }
  48.         mp.setLooping(true);
  49.         mp.start();
  50.     }
  51.  
  52.     @Override
  53.     public void onClick(View v) {
  54.  
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement