VideoView在日食不打手机日食、不打、手机、VideoView

2023-09-05 04:31:37 作者:过期爱

我已搜查每一个地方试图解决这一问题所以这就是为什么我来到这里,我把videoview在Eclipse的Andr​​oid应用程序,但视频不会在我的手机玩。

i have searched every where trying to fix this so that is why i came here i put a videoview in eclipse for an android app but the video will not play on my phone.

package test.test;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;


public class graphics extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    VideoView videoView = (VideoView) findViewById(R.id.test);
    MediaController mediaController = new MediaController (this);
    mediaController.setAnchorView(videoView);
    Uri video = Uri.parse("http://commonsware.com/misc/test2.3gp");
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(video);
    videoView.start();

    }
    } 

谢谢

推荐答案

我觉得问题在于无论是与连接(HTTP)或VideoView使用。

I think problem lies either with connectivity (http) or VideoView usage.

要知道,如果连接是问题,你可以尝试从SD卡播放媒体内容的本地到手机上,即

To know if the connectivity is the issue, you can try playing media content local to the phone, i.e. from SD Card.

的问题还可以由VideoView使用未来

Issues also be coming from VideoView usage

VideoView类使用SurfaceView和MediaPlayer的实现视频播放。 MediaPlayer的有API来设置URL,prepare媒体管道,启动管道等。但在此之前的管道可以启动;管道已准备就绪即$ P $宝龙条件。要通知应用程序这一点,提供的MediaPlayer听众。在这种情况下,它是在prepareListener。 VideoView它与MediaPlayer的还(有?)交互提供了这些听众也。

VideoView class uses SurfaceView and MediaPlayer to achieve Video Playback. MediaPlayer has APIs to set url, prepare the media pipeline, start the pipeline etc. But before pipeline can be started; the pipeline has to be ready i.e. in preroll condition. To notify application about this, MediaPlayer provides listeners. In this case it is onPrepareListener. VideoView which interacts with MediaPlayer also (has to ?) provides these listeners as well.

低于code进行外观的VideoPlayer活动,它使用VideoView进行播放。 (验证仅用于本地内容) 本次活动采用绝对路径的文件从意图播放。 (从列表活动通过)

Have a look below code for VideoPlayer activity which uses VideoView for playback. (Verified for local content only) This activity takes absolute path to file to be played from intent. (passed from list activity)

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;


public class VideoPlayer extends Activity implements OnCompletionListener, OnPreparedListener {
    private static VideoView vView;
    private String filePath;
    public static long clipDurationMS; 
    private View        mLoadingIndicator; 

    public void onCreate(Bundle savedInstanceState)     
    {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        vView = (VideoView)findViewById(R.id.VideoView01);
        mLoadingIndicator = findViewById(R.id.progress_indicator); 

        vView.setBackgroundColor(0x0000); 

        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        filePath = (String)extras.get("URL");

        vView.setVideoPath(filePath);  

        MediaController mc;
        mc = new MediaController(this);
        vView.setMediaController(mc);

        vView.requestFocus();
        vView.setOnCompletionListener(this);
        vView.setOnPreparedListener(this);
    }

    public void onCompletion(MediaPlayer arg0) 
    {
        finish();   
    }

    public void onPrepared(MediaPlayer arg0) 
    {
        mLoadingIndicator.setVisibility(View.GONE);
        ViewGroup.LayoutParams params;

        params        = vView.getLayoutParams();

        params.height = arg0.getVideoHeight();
        params.width  = arg0.getVideoWidth();

        vView.setLayoutParams(params);

        vView.start(); 
    }

    public void onStop(){
        super.onStop();
        vView.stopPlayback();
        finish();
    }
}

词shash

Shash