简体   繁体   中英

Can not play .3gp video in android videoview

Hi I downloaded and played the 3gp video referenced below using Android Video Player, but I can't find a way of playing it using the code below. My xml layout is defined as follow:

    <VideoView
    android:id="@+id/before_begin_video"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_centerInParent="true"
    android:layout_below="@id/before_begin_title" />

I have tried this code and doesn't work, only sound is played, but no video, only a black square:

    VideoView vView = (VideoView)findViewById(R.id.before_begin_video);
    MediaController mController = new MediaController(MABeforeBegin.this); 
    mController.setAnchorView(vView);
    Uri video = Uri.parse("https://dl.dropbox.com/s/xxxx/videoname.3gp?dl=0?client_id=xxxxxxx");
    vView.setMediaController(mController);
    vView.setVideoURI(video);
    vView.requestFocus();
    vView.start();

This code displays the media players I have on the phone:

    Uri video = Uri.parse("https://dl.dropbox.com/s/xxxx/videoname.3gp?dl=0?client_id=xxxxxxx");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setType("video/*");

    Intent intent0 = Intent.createChooser(intent, "Complete Action Using");
    startActivity(intent0);

But when I add intent.setData(video), the file chooser displays chrome, and other webbrowsers, but no video player like above

    Uri video = Uri.parse("https://dl.dropbox.com/s/xxxx/videoname.3gp?dl=0?client_id=xxxxxxx");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setType("video/*");
    intent.setData(video);

    Intent intent0 = Intent.createChooser(intent, "Complete Action Using");
    startActivity(intent0);

Finally found a way of solving this issue :

Before : I converted .avi to .3gp - .3gp doesn't run on HTC Sensation 4g

After : converted .avi to .mp4 - totally works!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM