Example usage for android.widget MediaController MediaController

List of usage examples for android.widget MediaController MediaController

Introduction

In this page you can find the example usage for android.widget MediaController MediaController.

Prototype

public MediaController(Context context) 

Source Link

Usage

From source file:nz.ac.auckland.lablet.script.components.CameraExperiment.java

public ScriptComponentCameraExperimentView(Context context, ScriptComponentSheetFragment sheetFragment,
        CameraExperiment cameraComponent) {
    super(context, sheetFragment, cameraComponent);
    this.cameraComponent = cameraComponent;

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.script_component_camera_experiment, null, false);
    assert view != null;

    addView(view);//from   w w w  . ja  va2  s. com

    TextView descriptionTextView = (TextView) view.findViewById(R.id.descriptionText);
    assert descriptionTextView != null;
    if (!cameraComponent.getDescriptionText().equals(""))
        descriptionTextView.setText(cameraComponent.getDescriptionText());

    Button takeExperiment = (Button) view.findViewById(R.id.takeExperimentButton);
    assert takeExperiment != null;
    takeExperiment.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            startExperimentActivity(new CameraSensorPlugin());
        }
    });

    videoView = (VideoView) view.findViewById(R.id.videoView);
    assert videoView != null;
    // Don't show a "Can't play this video." alert.
    videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            return true;
        }
    });
    MediaController mediaController = new MediaController(context);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);

    takenExperimentInfo = (CheckedTextView) view.findViewById(R.id.takenExperimentInfo);
    assert takenExperimentInfo != null;

    if (!cameraComponent.getExperiment().getExperimentPath().equals(""))
        onExperimentPerformed();
}

From source file:gov.wa.wsdot.android.wsdot.ui.camera.CameraVideoFragment.java

public void onLoadFinished(Loader<Boolean> loader, Boolean data) {
    mLoadingSpinner.setVisibility(View.GONE);

    if (data) {/*from www .j a  v  a  2s  .  c  o  m*/
        File f = new File(getActivity().getFilesDir(), mCameraName);

        mVideoView.setMediaController(new MediaController(getActivity()));
        mVideoView.setVideoURI(Uri.fromFile(f));
        mVideoView.requestFocus();

        mVideoView.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer arg0) {
                mLoadingSpinner.setVisibility(View.GONE);
                mVideoView.start();
            }
        });

        mVideoView.setOnErrorListener(new OnErrorListener() {
            public boolean onError(MediaPlayer mp, int what, int extra) {
                Toast.makeText(getActivity(), "Error occured", Toast.LENGTH_SHORT).show();
                return false;
            }
        });
    }
}

From source file:bupt.tiantian.callrecorder.callrecorder.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    checkPermissions();//from   www  .j  a  v  a2 s  .c o m

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            //???
            onListFragmentInteraction(new PhoneCallRecord[] {});
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    //set up MediaPlayer
    mediaController = new MediaController(this);
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setOnPreparedListener(this);
    mediaPlayer.setOnCompletionListener(this);

    //        RateMeNowDialog.showRateDialog(this, 10);

}

From source file:com.example.prasadnr.traquad.TraQuad.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tra_quad);
    ConnectivityManager connManager = (ConnectivityManager) getSystemService(TraQuad.CONNECTIVITY_SERVICE);
    NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    Builder alert = new AlertDialog.Builder(TraQuad.this);

    WifiManager managerWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    Method[] wmMethods = managerWifi.getClass().getDeclaredMethods();
    for (Method method : wmMethods) {
        if (method.getName().equals("isWifiApEnabled")) {

            try {
                isWifiAPenabled = (boolean) method.invoke(managerWifi);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();/*from www.ja  va  2s  . c om*/
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }

    final ProgressDialog pDialog;
    MediaController mediaController = new MediaController(this);

    pDialog = new ProgressDialog(TraQuad.this);
    pDialog.setTitle("TraQuad app (Connecting...)");
    pDialog.setMessage("Buffering...Please wait...");
    pDialog.setCancelable(true);

    if (!isWifiAPenabled) {

        alert.setTitle("WiFi Hotspot Settings");
        alert.setMessage("Can you please connect WiFi-hotspot?");
        alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                irritation = true;
                startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
                pDialog.show();
            }
        });
        alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //Dismiss AlertDialog
                pDialog.show();
                Toast.makeText(getApplicationContext(), "Please connect your WiFi!", Toast.LENGTH_LONG).show();
            }
        });
        alert.setCancelable(false);
        AlertDialog alertDialog = alert.create();
        alertDialog.show();
    }

    WebView webView = (WebView) findViewById(R.id.webView);

    if (irritation == true | isWifiAPenabled) {
        pDialog.show();
    }

    mediaController.setAnchorView(webView);
    mediaController.setVisibility(View.GONE);

    extra = getIntent().getStringExtra("VideosId");
    webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);

    final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
    final String IPaddressNew = globalVariable.getIP();
    final String httpString = "http://";
    final String commandPort = String.valueOf(1500);
    final String streamPort = String.valueOf(8080);
    final String IPaddressStream = httpString + IPaddressNew + ":" + streamPort;
    final String IPaddressCommand = httpString + IPaddressNew + ":" + commandPort;
    TextView sendCharacter = (TextView) findViewById(R.id.sendCharacter);

    try {
        webView.loadUrl(IPaddressStream);
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), IPaddressNew + ":Error!", Toast.LENGTH_LONG).show();
    }

    webView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            pDialog.dismiss();
        }
    });

    final Button switchact = (Button) findViewById(R.id.btn2);
    switchact.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent act1 = new Intent(view.getContext(), Joypad.class);
            startActivity(act1);

        }
    });

    final Button hometraquad = (Button) findViewById(R.id.button5);

    hometraquad.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            Intent acthometraquad = new Intent(TraQuad.this, MainActivity.class);
            startActivity(acthometraquad);
        }
    });

}

From source file:com.greatspeeches.slides.ScreenSlidePageFragment.java

public void update() {
    scroll.fullScroll(View.FOCUS_UP);
    if (mPersonObj.getType().equalsIgnoreCase("Popular") && !mPersonObj.getVideourl().contains("youtube")) {
        personImg.setVisibility(View.GONE);
        videoRel.setVisibility(View.VISIBLE);
        cVideoView.setVisibility(View.VISIBLE);
        cVideoView.setPlayPauseListener(new CustomVideoView.PlayPauseListener() {
            @Override//from  w  w w. ja  v a 2s .c o  m
            public void onPlay() {
                System.out.println("Play!");
            }

            @Override
            public void onPause() {
                System.out.println("Pause!");

            }
        });

        cVideoView.setMediaController(new MediaController(getActivity()));
        cVideoView
                .setVideoURI(Uri.parse("android.resource://com.greatspeeches/raw/" + mPersonObj.getVideourl()));
        cVideoView.start();
        cVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            public void onCompletion(MediaPlayer mp) {
                //               finish(); // finish current activity
                closeVplayer();
            }
        });
    } else {
        playYutubeVideo();
    }
}

From source file:com.pbi.live.VideoView.java

private void attachMediaController() {
    if (mLivePlayer != null) {
        mMediaController = new MediaController(getContext());
        mMediaController.setMediaPlayer(this);
        View anchorView = this.getParent() instanceof View ? (View) this.getParent() : this;
        mMediaController.setAnchorView(anchorView);
        mMediaController.setEnabled(true);
    }/* www.jav  a  2s  .c  o m*/
}

From source file:com.cardio3g.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);
    mDownloadViewGroup = (RelativeLayout) findViewById(R.id.downloadViewGroup);
    mDownloadProgressBar = (ProgressBar) findViewById(R.id.downloadProgressBar);
    mProgressPercentTextView = (TextView) findViewById(R.id.downloadProgressPercentTextView);
    mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
    mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this, DownloaderService.class);
    if (!expansionFilesDelivered()) {

        try {//ww  w  .j ava 2s.c  o m
            Intent launchIntent = MainActivity.this.getIntent();
            Intent intentToLaunchThisActivityFromNotification = new Intent(MainActivity.this,
                    MainActivity.this.getClass());
            intentToLaunchThisActivityFromNotification
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intentToLaunchThisActivityFromNotification.setAction(launchIntent.getAction());

            if (launchIntent.getCategories() != null) {
                for (String category : launchIntent.getCategories()) {
                    intentToLaunchThisActivityFromNotification.addCategory(category);
                }
            }

            // Build PendingIntent used to open this activity from
            // Notification
            PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0,
                    intentToLaunchThisActivityFromNotification, PendingIntent.FLAG_UPDATE_CURRENT);
            // Request to start the download
            int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this, pendingIntent,
                    DownloaderService.class);

            if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
                // The DownloaderService has started downloading the files, show progress
                initializeDownloadUI();
                return;
            } // otherwise, download not needed so we fall through to the app
        } catch (PackageManager.NameNotFoundException e) {
            Log.e("EXPANSION ERROR", "Cannot find package!", e);
        }
    } else {
        validateXAPKZipFiles();
    }

    btnBuiltIn = (Button) findViewById(R.id.button_builtin);
    btnMuscleIsolation = (Button) findViewById(R.id.button_muscle);
    btnCustomProgram = (Button) findViewById(R.id.button_custom);
    btnSportsTraining = (Button) findViewById(R.id.button_sports);
    btnhealthyLiving = (Button) findViewById(R.id.button_healthy);
    btnPersonalTrainer = (Button) findViewById(R.id.button_personal);
    btnVideos = (Button) findViewById(R.id.button_exercise_videos);
    btnCardio = (Button) findViewById(R.id.button_visit);
    btnImages = (Button) findViewById(R.id.button_exercise_photos);
    frameLayout = (FrameLayout) findViewById(R.id.frame);
    videoView = (VideoView) findViewById(R.id.video_view);
    btnBuiltIn.setOnClickListener(this);
    btnMuscleIsolation.setOnClickListener(this);
    btnCustomProgram.setOnClickListener(this);
    btnSportsTraining.setOnClickListener(this);
    btnhealthyLiving.setOnClickListener(this);
    btnPersonalTrainer.setOnClickListener(this);
    btnVideos.setOnClickListener(this);
    btnCardio.setOnClickListener(this);
    btnImages.setOnClickListener(this);

    mediaController = new MediaController(MainActivity.this);
    checkPermission();
}

From source file:com.data.pack.ViewVideo.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoplay);//  w w  w .  j a  va 2s  .  c om
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    filename = extras.getString("workoutname");
    workoutID = extras.getString("workoutID");
    UserName = extras.getString("UserName");
    userID = extras.getString("userID");
    // l= (View)findViewById(R.id.btnnavigation);
    btnQuit = (Button) findViewById(R.id.headeQuitricon);
    // btnplay =(Button)findViewById(R.id.btnplay);
    placeData = new PlaceDataSQL(this);
    GlobalData.appcount++;
    if (arrVoVideoName == null)
        arrVoVideoName = new ArrayList<VOWorkoutVideos>();
    GlobalData.viewvideochange = 0;
    if (videoPathes == null)
        videoPathes = new ArrayList<Object>();

    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;

    // params.screenBrightness = 10;
    getWindow().setAttributes(params);
    if (obUser.getSelectedLanguage().equals("1")) {
        YesString = "Yes";
        strLeaveVideo = "You are about to exit the Video. Are you sure ?";
        NoString = "No";
    } else {
        YesString = "Ja";
        QuitString = "verlassen";
        strLeaveVideo = "Du bist dabei das Video zu beenden, bist Du sicher ?";
        NoString = "Nein";
    }
    count = 1;
    // Toast.makeText(getBaseContext(), "countcountcountcount"
    // +count,Toast.LENGTH_LONG).show();
    // btnQuit =(Button) findViewById(R.id.headeQuitricon);
    btnQuit.setText(QuitString);
    btnQuit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // Intent intent = new Intent(sharescreen.this,
            // HomeScreen.class);
            // // intent.putExtra("userID", userID);
            // startActivity(intent);

            AlertDialog alertDialog = new AlertDialog.Builder(ViewVideo.this).create();
            if (mVideoView.isPlaying()) {
                mVideoView.pause();
            }

            alertDialog.setTitle("fitness4.me");
            alertDialog.setMessage(strLeaveVideo);

            alertDialog.setButton(-1, YesString, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        GlobalData.viewvideochange = 1;
                        Intent intent = new Intent(ViewVideo.this, FitnessforMeActivity.class);
                        startActivity(intent);
                        if (mVideoView != null)
                            mVideoView.stopPlayback();

                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            });
            alertDialog.setButton(-2, NoString, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    GlobalData.viewvideochange = 0;

                    mVideoView.start();

                    dialog.cancel();
                }
            });
            try {
                alertDialog.show();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    });
    mycontroller = new MediaController(this);
    mVideoView = (VideoView) findViewById(R.id.surface_view);
    mVideoView.setMediaController(null);
    AdView adView = (AdView) this.findViewById(R.id.adView);
    if (GlobalData.allPurchased == true) {

        adView.setVisibility(View.GONE);
    } else {
        adView.setVisibility(View.VISIBLE);
        adView.loadAd(new AdRequest());

    }

    try {
        myTimer = new Timer();
        myTimer.schedule(new TimerTask() {

            @Override
            public void run() {
                TimerMethod();
            }

        }, 1, 1000);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    mVideoView.setOnCompletionListener(myVideoViewCompletionListener);
    getDataAndPopulate();

}

From source file:com.ariesmcrae.mymemories.ui.story.StoryViewFragment.java

public void setUiToStoryData(long getUniqueKey) throws RemoteException {
    Log.d(LOG_TAG, "setUiToStoryData");
    storyData = resolver.getStoryDataViaRowID(getUniqueKey);

    if (storyData == null) {
        getView().setVisibility(View.GONE);
    } else { // else it just displays empty screen
        Log.d(LOG_TAG, "setUiToStoryData + storyData:" + storyData.toString());
        titleTV.setText(String.valueOf(storyData.title).toString());
        bodyTV.setText(String.valueOf(storyData.body).toString());

        audioButton.setOnClickListener(new OnClickListener() {
            @Override//from ww w.j a v  a  2s .  c o  m
            public void onClick(View v) {
                String audioLinkPath = String.valueOf(storyData.audioLink).toString();

                if (audioLinkPath != null && audioLinkPath.length() > 0) {
                    Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), Uri.parse(audioLinkPath));

                    if (!ringtone.isPlaying()) {
                        ringtone.play();
                    }
                }
            }
        });

        // Display the video
        String videoLinkPath = String.valueOf(storyData.videoLink).toString();

        if (videoLinkPath != null && videoLinkPath.length() > 0) {
            MediaController mediaController = new MediaController(getActivity());
            mediaController.setAnchorView(videoLinkView);
            videoLinkView.setMediaController(mediaController);
            videoLinkView.setVideoURI(Uri.parse(videoLinkPath));

            if (!videoLinkView.isPlaying()) {
                videoLinkView.start();
            }
        }

        // Display the image data
        imageNameTV.setText(String.valueOf(storyData.imageName).toString());

        String imageMetaDataPath = String.valueOf(storyData.imageLink).toString();
        imageMetaDataView.setImageURI(Uri.parse(imageMetaDataPath));

        Long time = Long.valueOf(storyData.storyTime);
        storyTimeTV.setText(StoryData.FORMAT.format(time));

        latitudeTV.setText(Double.valueOf(storyData.latitude).toString());
        longitudeTV.setText(Double.valueOf(storyData.longitude).toString());
    }
}

From source file:com.cw.litenote.util.video.VideoPlayer.java

private void setMediaController(final ViewPager pager) {
    System.out.println("VideoPlayer / _setMediaController");
    //MediaController
    mMediaController = new MediaController(mAct);
    mMediaController.setVisibility(View.VISIBLE);
    mMediaController.setAnchorView(UtilVideo.mVideoView);
    UtilVideo.mVideoView.setMediaController(mMediaController);

    mMediaController.setPrevNextListeners(
            // for next
            new View.OnClickListener() {
                public void onClick(View v) {
                    NoteUi.setFocus_notePos(NoteUi.getFocus_notePos() + 1);
                    if (NoteUi.getFocus_notePos() >= Note.mPagerAdapter.getCount())
                        NoteUi.setFocus_notePos(NoteUi.getFocus_notePos() - 1);
                    else
                        Note.changeToNext(pager);
                }//from   w ww .java 2  s  .  co m
            },
            // for previous
            new View.OnClickListener() {
                public void onClick(View v) {
                    NoteUi.setFocus_notePos(NoteUi.getFocus_notePos() - 1);

                    if (NoteUi.getFocus_notePos() < 0)
                        NoteUi.setFocus_notePos(NoteUi.getFocus_notePos() + 1);
                    else
                        Note.changeToPrevious(pager);
                }
            });
}