Soru & Cevap

videoview Bekleme Mesaji ...

30.09.2013 - 02:03

Videoview de bir video yuklenmesini beklerken yukleniyor yazip  beklemesini istiyorum. Bu konuda yardimci olabilirmisiniz?

13 Görüntülenme

3 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-4816-1393230227.jpg
selim.tekinarslan
01.10.2013 - 11:02

onprogressupdate için her progressi heseplama gerekli o yüzden daha kolay yoldan gidelim. 

Linkteki örneği indir ve eclipse de import de. Ben run ettim ve istediğin gibi çalışıyor. 

http://www.androidbegin.com/tutorial/android-video-streaming-videoview-tutorial/

 

Kolaylıklar

Profile picture for user sultan
sultan
30.09.2013 - 05:12

 

 

public class IzleActivity extends Activity {

MediaController media;

    VideoView ekran;

    String url;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_izle);

        ekran = (VideoView) findViewById(R.id.videoView1);

         Intent in = getIntent();

        url = in.getStringExtra("LIVE");

         new BackgroundAsyncTask().execute(url);

    }

    public class BackgroundAsyncTask extends AsyncTask<String, Uri, Void> {

        Integer track = 0;

        ProgressDialog dialog;

        protected void onPreExecute() {

            dialog = new ProgressDialog(IzleActivity.this);

            dialog.setMessage("Yukleniyor");

            dialog.setCancelable(true);

            dialog.show();

        }

        protected void onPostExecute(final Boolean success) {

           

        }

        protected void onProgressUpdate(final Uri... uri) {

            try {

                media=new MediaController(IzleActivity.this);

                ekran.setMediaController(media);

                media.setPrevNextListeners(new View.OnClickListener() {

                    @Override

                    public void onClick(View v) {

                     }

                }, new View.OnClickListener() {

                    @Override

                    public void onClick(View v) {

                        finish();

                    }

                });

                media.show(90);

                ekran.setVideoURI(uri[0]);

                ekran.requestFocus();

                ekran.setOnPreparedListener(new OnPreparedListener() {

                    public void onPrepared(MediaPlayer arg0) {

                        ekran.start();

                         dialog.dismiss();

                    }

                    

                });

            } catch (IllegalArgumentException e) {

                e.printStackTrace();

            } catch (IllegalStateException e) {

                e.printStackTrace();

            } catch (SecurityException e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            }

        }

        @Override

        protected Void doInBackground(String... params) {

           

            try {

                Uri uri = Uri.parse(params[0]);

                    publishProgress(uri);  

            } catch (Exception e) {

                e.printStackTrace();

            }

            return null;

        }

    }

 

Benim kodum bu. Fakat video sayfasi acilinca yukleniyor yazip hemen gidiyo sonra uzunca bekliyor ve sonra video aciliyor. Nasil duzenlemem lazim ?

picture-4816-1393230227.jpg
selim.tekinarslan
30.09.2013 - 03:52

Videoview i bir asynTask da çalıştırırsanız video yüklemesini gösterebilirsiniz. AsynTask da onpre.. methodunda yükleniyor dialog açıp doingbackground methodunda download yapıp post execute da start edersiniz ve kullanıcı start olana kadar dialog görür. 

Türkçe anlatım AsynTask için,

http://kadiranilturgut.com/android-asynctask/

Benzer bir yöntemde linkde mevcut.

http://oodlestechnologies.com/blogs/Working-with-MediaController,--VideoView-in-Android

Kolaylıklar,