Streaming Media Development-loading server Images

Source: Internet
Author: User

Cocoa studio:

Welcome to Coco live video player:

Http://pan.baidu.com/share/link? Consumer id = 3291150676 & UK = 4111208708

We need to display TV station icons when developing live videos, and OOM is also common. To solve this problem, I used an open source online network image loading tool Android-universal-image-loader, its official website https://github.com/nostra13/Android-Universal-Image-Loader can help us solve this problem, and variety, the Code not only provides the source code but also provides the demo instance. Let's take a look at the image of its official instance:



Of course, we can define the layout by ourselves. The following describes the precautions for use:

1. First, you must add

public static void initImageLoader(Context context) {// This configuration tuning is custom. You can tune every option, you may tune some of them,// or you can create default configuration by//  ImageLoaderConfiguration.createDefault(this);// method.ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).writeDebugLogs() // Remove for release app.build();// Initialize ImageLoader with configuration.ImageLoader.getInstance().init(config);}

Otherwise, when you use imageloader, you will be prompted to use it only after init.

2. Live streaming generally obtains server data, so we also need to parse the data returned by the server (which may be JSON or XML). We can put the parsed data in the list, then, call getview In the adapter.

Imageloader. displayimage (imageurls [position], Holder. Image, options, animatefirstlistener );

The animatefirstlistener is:

private static class AnimateFirstDisplayListener extends SimpleImageLoadingListener {static final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());@Overridepublic void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {if (loadedImage != null) {ImageView imageView = (ImageView) view;boolean firstDisplay = !displayedImages.contains(imageUri);if (firstDisplay) {FadeInBitmapDisplayer.animate(imageView, 500);displayedImages.add(imageUri);}}}}

This is done, which is very convenient.

Welcome to Coco live video player:

Http://pan.baidu.com/share/link? Consumer id = 3291150676 & UK = 4111208708

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.