VLC-based video player and VLC Video Player

Source: Internet
Author: User

VLC-based video player and VLC Video Player

I recently studied the video playback function, which was previously used by VideoView. After reading the video on the internet, I feel that it is not very good, and the supported formats are relatively small. Now there are various formats of online videos, and I feel that it is very limited to play with VideoView.

Found a suitable player, Github address for https://github.com/xiaomo/AndroidPlayerLibrary. This player is based on the vlc software. After importing our demo to Eclipse, We can find such a libvlc folder.

In the Media class, we can find that there are many supported formats.

String[] video_extensions = {                ".3g2", ".3gp", ".3gp2", ".3gpp", ".amv", ".asf", ".avi", ".divx", ".drc", ".dv",                ".f4v", ".flv", ".gvi", ".gxf", ".ismv", ".iso", ".m1v", ".m2v", ".m2t", ".m2ts",                ".m4v", ".mkv", ".mov", ".mp2", ".mp2v", ".mp4", ".mp4v", ".mpe", ".mpeg",                ".mpeg1", ".mpeg2", ".mpeg4", ".mpg", ".mpv2", ".mts", ".mtv", ".mxf", ".mxg",                ".nsv", ".nut", ".nuv", ".ogm", ".ogv", ".ogx", ".ps", ".rec", ".rm", ".rmvb",                ".tod", ".ts", ".tts", ".vob", ".vro", ".webm", ".wm", ".wmv", ".wtv", ".xesc" };String[] audio_extensions = {                ".3ga", ".a52", ".aac", ".ac3", ".adt", ".adts", ".aif", ".aifc", ".aiff", ".amr",                ".aob", ".ape", ".awb", ".caf", ".dts", ".flac", ".it", ".m4a", ".m4b", ".m4p",                ".mid", ".mka", ".mlp", ".mod", ".mpa", ".mp1", ".mp2", ".mp3", ".mpc", ".mpga",                ".oga", ".ogg", ".oma", ".opus", ".ra", ".ram", ".rmi", ".s3m", ".spx", ".tta",                ".voc", ".vqf", ".w64", ".wav", ".wma", ".wv", ".xa", ".xm" };

In this example, it writes a PlayerActivity and PlayerView, and implements the IVideoPlayer interface in libvlc in PlayerView.

 

Implement the PlayerView class in PlayerActivity to control the interface and process.

Protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); mUrl = getIntent (). getStringExtra ("url"); if (TextUtils. isEmpty (mUrl) {Toast. makeText (this, "error: no url in intent! ", Toast. LENGTH_SHORT ). show (); return;} requestWindowFeature (Window. FEATURE_NO_TITLE); getWindow (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); setContentView (R. layout. activity_player); mHandler = new Handler (this); tvTitle = (TextView) findViewById (R. id. TV _title); tvTime = (TextView) findViewById (R. id. TV _time); tvLength = (TextView) findViewById (R. id. TV _length); sbVideo = (SeekBar) findViewById (R. id. sb_video); sbVideo. setOnSeekBarChangeListener (this); ibLock = (ImageButton) findViewById (R. id. ib_lock); ibLock. setOnClickListener (this); ibBackward = (ImageButton) findViewById (R. id. ib_backward); ibBackward. setOnClickListener (this); ibPlay = (ImageButton) findViewById (R. id. ib_play); ibPlay. setOnClickListener (this); ibFarward = (ImageButton) findViewById (R. id. ib_forward); ibFarward. setOnClickListener (this); ibSize = (ImageButton) findViewById (R. id. ib_size); ibSize. setOnClickListener (this); loverlay = findViewById (R. id. ll_overlay); rlOverlayTitle = findViewById (R. id. rl_title); rlLoading = findViewById (R. id. rl_loading); tvBuffer = (TextView) findViewById (R. id. TV _buffer); // usage step // Step 1: Get the mPlayerView object through findViewById or new PlayerView () // mPlayerView = new PlayerView (PlayerActivity. this); mPlayerView = (PlayerView) findViewById (R. id. pv_video); // Step 2: Set the parameter in milliseconds (unit: mPlayerView. setNetWorkCache (20000); // Step 3: Initialize the player mPlayerView. initPlayer (mUrl); // Step 4: Set the event listener and monitor the buffer progress and other mplayerviews. setOnChangeListener (this); // Step 5: start playing the mPlayerView. start (); // init view tvTitle. setText (mUrl); showLoading (); hideOverlay ();}

How to use this class library

Library:

First, directly add a new PlayerView or embed the view in the xml of the layout file.

Second, jump to a prepared PlayerActivity page (local file parameter format: file: // sacard/test. rmvb .)

Here I chose the second method.

startActivity(new Intent(this, PlayerActivity.class).putExtra("url", items.get(position)));

Click each item in the form of a selection list and pass a url to PlayerActivity.

Select 1.2jdkdownload .mp4

There is no problem with switching between landscape and landscape screens.

If you have a good player, you are welcome to contact me.

 

Author: Jerry Education
Source: http://www.cnblogs.com/jerehedu/
The copyright of this article belongs to Yantai Jerry Education Technology Co., Ltd. and the blog Park. You are welcome to repost it. However, you must keep this statement without the author's consent and provide the original article connection on the article page, otherwise, you are entitled to pursue legal liability.

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.