package com.example.fragmentdynamic;

import com.example.fragmentdynamic.CommandVideoFragment.OnCommandVideoListener;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.net.Uri;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoFragment 	extends Fragment
							implements OnCommandVideoListener{
	
	 VideoView video_player_view;
	 MediaController media_Controller;
	    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.video_fragment, container, false);        
    }
    
    @Override
    public void onStart() {
    	getVideoInit();
    	super.onStart();
    	
      
    }
    
 

    public void getVideoInit() {
        video_player_view = (VideoView) getActivity().findViewById(R.id.videoView1);
        media_Controller = new MediaController(getActivity());
       // Uri uri = Uri.parse("android.resource://" + getActivity().getPackageName() + "/"+R.raw.airhorse);
        video_player_view.setMediaController(media_Controller);
        video_player_view.setVideoPath("/sdcard/Movies/robot.mp4");
       // video_player_view.start();
    }

	@Override
	public void onClickVideoCommand(CommandVideo command) {
		// TODO Auto-generated method stub
	switch 	(command){
		case START:  video_player_view.start(); break;
		case PAUSE:  video_player_view.pause(); break;
		case STOP:  video_player_view.stopPlayback(); break;
		default:
		
	}
	}
	 
}
