Use Vitamio to build your Android Universal player (5)--Play online (play Youku video)

Source: Internet
Author: User

Objective

In order to ensure the progress of a weekly article, and because the new version of Vitamio is not released, decided to postpone some local playback of some functions (, video time, size, etc.), skip directly write the section of the online play part. As you can see from Vitamio's introduction, it supports various network protocols such as HTTP, m3u8, and this chapter will write an example of playing Youku video. StatementWelcome reprint, but please keep the original source of the article:) Blog Park: http://www.cnblogs.com farmer Uncle: http://over140.cnblogs.com Series1. Use Vitamio to build your Android Universal player (1)--Prepare 2, use Vitamio to build your Android Universal player (2)--gesture control brightness, volume, zoom 3, Use Vitamio to build your Android Universal player (3)--local play (main interface, video list)

4. Use Vitamio to build your own Android Universal player (4)-Local playback (fast search, data storage)

BodyFirst, the goal

1, formally named " Premiere Video ", the original intention: "Open source video player", there is also "start playing video" simple meaning, I hope you like:)

2, the use of embedded Youku (3g.youku.com) way, directly play video files.

Second, the realization

Fragmentonline

PublicClass FragmentonlineExtends Fragmentbase {

Private WebView Mwebview;

@Override
Public View Oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {
View v = inflater.inflate (r.layout.fragment_online, container,FALSE);
Mwebview = (WebView) V.findviewbyid (R.id.webview);
Mwebview.setscrollbarstyle (View.scrollbars_outside_overlay);
Mwebview.getsettings (). setjavascriptenabled (true);
Mwebview.getsettings (). setpluginsenabled (true);
Mwebview.loadurl ("http://3g.youku.com");
Mwebview.setwebviewclient (New Webviewclient () {
@Override
Publicvoid onpagefinished (WebView view, String URL) {
};

/**Page Jump*/
@Override
PublicBoolean shouldoverrideurlloading (WebView view, String URL) {
if (Fileutils.isvideooraudio (URL)) {
Intent Intent =New Intent (Getactivity (), videoplayeractivity.Class);
Intent.putextra ("path", url);
StartActivity (Intent);
ReturnTrue
}
ReturnFalse
};
});

Mwebview.setonkeylistener (New Onkeylistener () {

@Override
PublicBoolean OnKey (View V,int KeyCode, KeyEvent event) {
if (keycode = = keyevent.keycode_back) && Mwebview! =Null && mwebview.cangoback ()) {
Mwebview.goback ();
return true;
}
return false;
}
});
return v;
}

}

Code Description:

Because of the embedded 3g.youku.com, the page layout is very good, and it is easy to get the playback address, just listen to the page jump.

a). OnKey handles the back event, returning to the previous page

b). Note Webviewclinet's Shouldoverrideurlloading method, if the return True page will not perform a jump, here will be improved later, the playback fails directly using the browser flash playback.

c). Fragment_online's layout is not posted here, it is a webview control.

Third, download

Vitamio-demo2012-6-15.zip

FourWarning

Video, books, music are very strict areas of copyright, how to avoid copyright issues is a matter that needs serious consideration. Consult a friend, this article takes the way is can, generally to determine whether there is copyright is to see whether to remove ads, happen to 3g.youku.com video is not with ads, direct MP4 file playback.

V. RELATED articles

Get the real address of Youku video by anti-compilation

Youku Network Video Address acquisition principle

Youku Video Real Address resolution

Vi. Vitamio and related

Vitamio:http://vov.io

vplayer:http://vplayer.net(more than 5 million users using Vitamio's most successful products)

EndHere is to take m3u8 address, also has been taken, but the current version of the Vitamio can not play the resolved address, also directly use the address of MP4, simple aspects, this issue and subsequent version has been repaired, from the new vplayer we can look at the effect. Although so far just a demo, still trying to move towards a formal product, I hope to the end of the series can be officially released to the app Store for users to use, but also welcome more suggestions ~ ~

Use Vitamio to build your Android Universal player (5)--Play online (play Youku video)

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.