Introduction to common methods of Android MediaPlayer

Source: Internet
Author: User
Tags time in milliseconds

Introduction to common methods of Android MediaPlayer


Method: Create (context context, URI Uri)
Explanation: A static method that creates a multimedia player from a URI.

Method: Create (context context, int resid)
Explanation: Static method, creating a multimedia player with resource ID

Method: Create (context context, Uri Uri, Surfaceholder holder)
Explanation: A static method that creates a multimedia player by URI and specifying Surfaceholder "abstract class"

Method: GetCurrentPosition ()
Explanation: Return Int to get the current playback position

Method: Getduration ()
Explanation: Return Int, time to get the file

Method: Getvideoheight ()
Explanation: Return Int to get the height of the video

Method: Getvideowidth ()
Explanation: Return Int to get the width of the video

Method: Islooping ()
Explanation: Returns Boolean, whether to loop playback

Method: IsPlaying ()
Explanation: Returns a Boolean, whether it is playing

Method: Pause ()
Explanation: No return value, pause

Method: Prepare ()
Explanation: No return value, ready to synchronize

Method: Prepareasync ()
Explanation: No return value, ready for asynchronous

Method: Release ()
Explanation: No return value, Release MediaPlayer object

Method: Reset ()
Explanation: No return value, reset MediaPlayer object

Method: Seekto (int msec)
Explanation: No return value, specifying the playback position (time in milliseconds)

Method: Setaudiostreamtype (int streamtype)
Explanation: No return value, specifying the type of streaming media

Method: Setdatasource (String path)
Explanation: No return value, set multimedia data source "according to Path"

Method: Setdatasource (filedescriptor fd, long offset, long length)
Explanation: No return value, set multimedia data source "according to FileDescriptor"

Method: Setdatasource (FileDescriptor FD)
Explanation: No return value, set multimedia data source "according to FileDescriptor"

Method: Setdatasource (context context, URI Uri)
Explanation: No return value, set multimedia data source "according to Uri"

Method: Setdisplay (Surfaceholder sh)
Explanation: No return value, set to use Surfaceholder to display multimedia

Method: Setlooping (Boolean looping)
Explanation: No return value, setting whether to loop playback

Event: Setonbufferingupdatelistener (Mediaplayer.onbufferingupdatelistener Listener)
Explanation: Monitoring events, buffer monitoring of network streaming media

Event: Setoncompletionlistener (Mediaplayer.oncompletionlistener Listener)
Explanation: Listening events, network streaming media playback end monitoring

Event: Setonerrorlistener (Mediaplayer.onerrorlistener Listener)
Explanation: Listen for events, set error messages to listen

Event: Setonvideosizechangedlistener (Mediaplayer.onvideosizechangedlistener Listener)
Explanation: Monitoring events, video size monitoring

Method: Setscreenonwhileplaying (Boolean Screenon)
Explanation: No return value, setting whether to use Surfaceholder display

Method: SetVolume (float leftvolume, float rightvolume)
Explanation: No return value, set volume

Method: Start ()
Explanation: No return value to start playback

Method: Stop ()
Explanation: No return value, stop playback

Introduction to common methods of Android MediaPlayer

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.