Android uses Vitamio to build its own universal player (6)--Online playback (playlist) _android

Source: Internet
Author: User

Objective

The new version of Vplayer from the design into the development phase, the development cycle is expected to be one months, which means that the new version of the Vitamio will be released, developers can and this series of articles, like the first development of other features. This chapter is "online video playlist", a collection of mainstream major video site mobile phone version, welcome to the "premiere video" Feedback Suggestions for improvement!

Series

1. Android uses Vitamio to build its own universal player (1)--ready

2, Android uses Vitamio to build its own Android Universal player (2)--gesture control brightness, volume, zoom

3, Android use Vitamio to build their own Android Universal player (3)--local playback (main interface, video list)

4, Android use Vitamio to build their own Android Universal player (4)--Local playback (fast search, data storage)

5, Android use Vitamio to build their own Android Universal player (5)--Play online (play cool video)

Body

I. Objectives

Integration of the major video site mobile phone version, screenshot:

Second, the implementation of the Code

public class Fragmentonline extends Fragmentbase implements Onitemclicklistener {/** cache video list */private static Array
  list<string[]> monlinelist = new arraylist<string[]> ();
  /** Cache Video Logo list */private static arraylist<integer> monlinelogolist = new arraylist<integer> ();
  Private WebView Mwebview;

  Private ListView Mlistview;
    @Override public View Oncreateview (layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {
    View Mview = inflater.inflate (R.layout.fragment_online, container, false); Mlistview = (ListView) Mview.findviewbyid (Android.
    R.id.list);
    Mwebview = (webview) Mview.findviewbyid (R.id.webview);
    Mlistview.setonitemclicklistener (this);
    Initwebview ();
    Mlistview.setadapter (New DataAdapter (Getactivity ()));
  return mview; @Override public void Onitemclick (adapterview<?> parent, view view, int position, long ID) {final
    String[] f = monlinelist.get (position);Mwebview.clearview ();
    Mwebview.loadurl (f[1]);
    Mwebview.clearhistory ();
    Mlistview.setvisibility (View.gone);
  Mwebview.setvisibility (view.visible);
      @Override public boolean onbackpressed () {if (Mlistview = null | | | mlistview.getvisibility () = view.visible)
    return super.onbackpressed ();
      else {mlistview.setvisibility (view.visible);
      Mwebview.setvisibility (View.gone);
    return true; 
    }/** Initialize WebView * * private void Initwebview () {Mwebview.setscrollbarstyle (view.scrollbars_outside_overlay);
    Mwebview.getsettings (). Setjavascriptenabled (True);

    Mwebview.getsettings (). Setpluginsenabled (True);  Mwebview.setwebviewclient (New Webviewclient () {@Override public void onpagefinished (webview view, String URL)

      {
      }; /** Page Jump * * @Override public boolean shouldoverrideurlloading (webview view, String URL) {if (fileutil S.isvideooraudio (URL)) {Intent Intent = new Intent(Getactivity (), videoplayeractivity.class);
          Intent.putextra ("path", url);
          StartActivity (Intent);
        return true;
      return false;
    };

    }); Mwebview.setonkeylistener (New Onkeylistener () {@Override public boolean onkey (View v, int keycode, keyevent Event) {if ((keycode = = keyevent.keycode_back) && mwebview!= null && mwebview.cangob
          ACK ()) {mwebview.goback ();
        return true;
      return false;
  }
    }); } private class DataAdapter extends Arrayadapter<string[]> {public DataAdapter (context ctx) {super (C
    TX, monlinelist); @Override public View getview (int position, View Convertview, ViewGroup parent) {Final string[] f = Geti
      TEM (position);
        if (Convertview = null) {final Layoutinflater minflater = getactivity (). Getlayoutinflater (); Convertview = minflater.inFlate (R.layout.fragment_online_item, NULL); ((ImageView) Convertview.findviewbyid (R.id.thumbnail)). Setimageresource (Monlinelogolist.get (position))
      ;

      ((TextView) Convertview.findviewbyid (R.id.title)). SetText (f[0));
    return convertview;
    } static {//Monlinelist.add (new string[] {"Youku video", "Http://3g.youku.com"});
    Monlinelogolist.add (R.drawable.logo_youku);
    Monlinelist.add (new string[] {"Sohu video", "Http://m.tv.sohu.com"});
    Monlinelogolist.add (R.drawable.logo_sohu);
    Monlinelist.add (new string[] {"Le-view TV", "http://m.letv.com"});
    Monlinelogolist.add (R.DRAWABLE.LOGO_LETV);
    174 Monlinelist.add (new string[] {"Love singular", "http://3g.iqiyi.com/"});
    Monlinelogolist.add (R.drawable.logo_iqiyi);
    Monlinelist.add (new string[] {"PPTV", "http://m.pptv.com/"});
    Monlinelogolist.add (R.DRAWABLE.LOGO_PPTV); 181 Monlinelist.add (New string[] {"Tencent video", "http://3g.v.qq.com/"});
    Monlinelogolist.add (R.DRAWABLE.LOGO_QQ);
    Monlinelist.add (new string[] {"56.com", "http://m.56.com/"});
    Monlinelogolist.add (r.drawable.logo_56);
    Monlinelist.add (new string[] {"Sina video", "http://video.sina.cn/"});
    Monlinelogolist.add (R.drawable.logo_sina);
    Monlinelist.add (new string[] {"Potato video", "Http://m.tudou.com"});
  Monlinelogolist.add (R.drawable.logo_tudou);  }
}

Code Description:

a). The 3g version of each major website provides a MP4 format of the play link, where the integration can be.

(b). To handle the back event, press the WebView page to jump to the previous page.
(c). Empty history and switch video sites to prevent back to other sites.

Other code reference project source.

Third, other update log

Added: New logo enabled

Repair: Automatically close the window after playing

FIX: Switch between local video and online video error

End

Again, remind developers to use the Vitamio to play the problem video, please use the latest version of the Vplayer to test, if there is no issue of the new release of the Vitamio will not be a problem.

Related Article

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.