please tell me. I have a link to the video. I have a VideoView. He plays some video formats. How can I play the video from the Internet to another format? how to decode it? or are there other ways?

package com.example.MyVideo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;

public class MyActivity extends Activity implements View.OnClickListener {
    /**
     * Called when the activity is first created.
     */
    private Button btn;
    private VideoView vv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn = (Button) findViewById(R.id.button);
        btn.setOnClickListener(this);
        vv = (VideoView) findViewById(R.id.videoView);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.button:
                vv.setVideoURI(link);
                break;
        }
    }
}
有帮助吗?

解决方案

If you want to view the url directly in videoview, use like this:

 VideoView mVideoView;
 MediaController mcon;
 String videourl="http://ww.abc.com/a";
 mVideoView = (VideoView) findViewById(R.id.videoview);
 mVideoView.setVideoURI(Uri.parse(videourl));
 mVideoView.start();

If you want to download videos from url and save in sd card, better use webview and
WeViewClient handles the url. See this tutorial

http://androidtrainningcenter.blogspot.in/2013/11/download-file-videoaudiotext-through.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top