Vitamio Chinese API documentation (3) -- MediaController

Source: Internet
Author: User


Preface

MediaController is used together with VideoView to implement the main functions of the playback interface. You can refer to OPlayer code for implementation.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Vitamio: http://www.vitamio.org

Farmer's uncle: http://www.cnblogs.com/over140/

 

Body 

MediaController

Sorting: peasant uncle

Class Overview

Public class MediaController extends FrameLayout

A media control bar that contains a Media Player (MediaPlayer. It usually includes "play/pause" and SeekBar. It manages the status of MediaPlayer to maintain control synchronization.

The method of using this class:

A). instantiate this class through programming.

This media controller creates controls with default settings and places them in a window floating on your application. Specifically, these controls float on the view specified by setAnchorView. If the window is idle for 3 seconds, it disappears until it is reproduced when you touch the view. To customize the style, layout, and control of MediaController, you can extend MediaController to overwrite makeControllerView.

B). Create an xml layout.

MediaController is a FrameLayout, which can be placed in your layout and obtained through findViewById.

Note: If you want to customize MediaController, The SeekBar id must be "mediacontroller_progress", "mediacontroller_pause", and "mediacontroller_time_current ", the total time must be "mediacontroller_time_total", and the file name must be "mediacontroller_file_name ". You must also have pause_button and play_button resources (drawable ).

When MediaController is created through xml layout, functions such as show () and hide () are invalid.

Common Methods

Public voidOnFinishInflate()

It is called after loading all child views from XML. Initialize the control view (call the initControllerView method to set events, bind controls, and set default values ).

Public voidSetAnchorView(View view)

Set MediaController to bind to a view. For example, it can be a VideoView object or the main view of your activity.

Parameters

View bound when the view is visible

Public voidSetMediaPlayer(MediaPlayerControl player)

Set the media player. And update the playback/pause button status.

Public voidSetInstantSeeking(Boolean seekWhenDragging)

Set whether the screen changes when you drag the SeekBar. (Update the image after VPlayer completes the operation by default)

Public voidShow()

Display MediaController. It is automatically hidden after 3 seconds by default.

Public voidShow(Int timeout)

Display MediaController. In timeoutAutomatically hidden in milliseconds.

Parameters

TimeoutTimeout time, in milliseconds. 0Hide ()Will be called.

Public voidSetFileName(String name)

Set the video file name.

Public voidSetInfoView(OutlineTextView v)

Set to save MediaController operation information. For example, update v when the progress changes.

Public voidSetAnimationStyle(Int animationStyle)

Change the animation style of MediaController.

If MediaController is displayed, calling this method will take effect the next time it is displayed.

Parameters

Animation style used when the MediaController is displayed or hidden. Set-1 to the default style, 0 to no animation, or set a clear animation resource.

Public booleanIsShowing()

Obtain whether the MediaController is displayed.

Public voidHide()

Hide MediaController.

Public voidSetOnShownListener(OnShownListener l)

Registers a callback function and is called after the MediaController is displayed.

Public voidSetOnHiddenListener(OnHiddenListener l)

Register a callback function, which is called after the MediaController is hidden.

Public booleanOnTouchEvent(MotionEvent event)

Call show () and return true.

Public booleanOnTrackballEvent(MotionEvent ev)

Call show () and return false.

Public voidSetEnabled(Boolean enabled)

Set the available status of MediaController. Including the progress bar and the play/pause button.

Protected Methods

Protected ViewMakeControllerView()

Create a layout view that controls playback. Subclass can override this method to create a custom view.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.