Getting error (1, -2147483648) for my device which have version 4.4.2

0

This is my code.

public class MainActivity extends Activity {
    ListView listview;
    CustomListAdapter adapter;
    private static ProgressDialog progressDialog;
    public static int currentItem;
    public static ArrayList<String> videoLIst;
    public static MediaController mediaController ;
    boolean pauseOnScroll = true;
    boolean pauseOnFling = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view);
        System.gc();
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
        videoLIst = new ArrayList<String>();
         mediaController = new MediaController(MainActivity.this); 
        videoLIst.add("http://journey.coderspreview.com/uploads/Home_Video/mov_bbb.mp4");
        videoLIst.add("http://journey.coderspreview.com/uploads/experience/165/video/father-and-young-daughter.mp4");
        videoLIst.add("http://journey.coderspreview.com/uploads/experience/185/video/couple-on-sail-boat.mp4");
        videoLIst.add("http://journey.coderspreview.com/uploads/experience/39/video/VID-20141231-WA0006.mp4");
        videoLIst.add("http://journey.coderspreview.com/uploads/experience/26/video/VID-20141216-WA0004.mp4");
        listview = (ListView) findViewById(R.id.list);
        listview.setFastScrollEnabled(true);
        listview.setAdapter(new CustomListAdapter(this, videoLIst));
        listview.setScrollingCacheEnabled(false);
         listview.setRecyclerListener(new RecyclerListener() {
                @Override
                public void onMovedToScrapHeap(View view) {
                    VideoView videoView = (VideoView)view.findViewById(R.id.VideoView);

                }
            });

      listview.setOnScrollListener(new AbsListView.OnScrollListener() {
          private int mFirstVisibleRow = -1;
          private int mActiveItem = -1;

          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
               VideoView videoView = (VideoView)view.findViewById(R.id.VideoView);
               if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                   videoView.destroyDrawingCache();
               } else {
                   videoView.buildDrawingCache();
               }
          }


          @Override
          public void onScroll(AbsListView view, int firstVisibleItem,
                               int visibleItemCount, int totalItemCount) {
              int firstVisibleRow = listview.getFirstVisiblePosition();
              int lastvisiblerow =listview.getLastVisiblePosition();
              if( mFirstVisibleRow != firstVisibleRow )
              {
                  mFirstVisibleRow = firstVisibleRow;

                  // Cancel the video of the previous active item
                  VideoView prevActiveVideoView = getVideoViewForRow(mActiveItem);
                  if( prevActiveVideoView != null )
                  {
                      prevActiveVideoView.pause();
                      prevActiveVideoView.clearAnimation();
//                      prevActiveVideoView.destroyDrawingCache();
                  }

                  // Start the video of the new active item
                  mActiveItem = mFirstVisibleRow + 1;
                  VideoView newActiveVideoView = getVideoViewForRow(mActiveItem);
                  if(newActiveVideoView != null)
                  {
                      newActiveVideoView.start();
//                      newActiveVideoView.buildDrawingCache();

                  }
              }

                  VideoView lastVideoView = getVideoViewForRow(lastvisiblerow);
                  if(lastVideoView != null)
                  {
                      lastVideoView.pause();
                  }

          }

          private VideoView getVideoViewForRow(int row)
          {
              int firstVisibleRow = listview.getFirstVisiblePosition();
              View rowView = listview.getChildAt(row-firstVisibleRow);
              return (rowView == null) ? null : (VideoView)rowView.findViewById(R.id.VideoView);
          }

      });

    }
    static class ViewHolderItem {

                TextView textViewItem;
                VideoView video;
                ProgressBar progressbar;
            }

    public class CustomListAdapter extends BaseAdapter {
        private Activity activity;
        private LayoutInflater inflater;
        private ArrayList<String> videoList;

        public CustomListAdapter(Activity activity, ArrayList<String> videoList) {
            this.activity = activity;
            this.videoList = videoList;
        }

        @Override
        public int getCount() {
            return videoList.size();
        }

        @Override
        public Object getItem(int location) {
            return videoList.get(location);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @SuppressLint("NewApi")
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

             Log.d("in getview method:",""+position);
             final ViewHolderItem viewHolder;


             if (convertView == null){
                  inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  convertView = inflater.inflate(R.layout.video_list_item, null);

                   viewHolder = new ViewHolderItem();
                   viewHolder.video = (VideoView)convertView.findViewById(R.id.VideoView);
                   viewHolder.progressbar = (ProgressBar)convertView.findViewById(R.id.progress);

                   viewHolder.textViewItem =(TextView)convertView.findViewById(R.id.txvposition);


                   int pos;
                   pos=viewHolder.video.getCurrentPosition();
                   Log.d("current item position:",""+pos);
                    convertView.setTag(viewHolder);

             }else{
                viewHolder = (ViewHolderItem) convertView.getTag();

             }

             viewHolder.textViewItem.setText("Video"+position);
//             mediaController.setAnchorView(viewHolder.video);
             Log.d("video url inadapter:", ""+videoLIst.toString());
             Uri uri = Uri.parse(videoList.get(position));
            // viewHolder.video.setMediaController(mediaController);
           //  viewHolder.video.setVideoURI(uri);
             new Handler().postDelayed(new Runnable() {

                 @Override
                 public void run() {
//                   viewHolder.video.setVisibility(View.GONE);
//                   viewHolder.video.setVisibility(View.VISIBLE);
                     viewHolder.video.setVideoURI(Uri.parse(videoList.get(position)));
                     viewHolder.video.setBackgroundColor(Color.TRANSPARENT);
                }
            }, 100);
             //viewHolder.video.start();
             viewHolder.video.setOnPreparedListener(new OnPreparedListener() {
                     public void onPrepared(final MediaPlayer arg0) {
                           viewHolder.progressbar.setVisibility(View.GONE);
                           viewHolder.video.start();
                           viewHolder.video.setBackgroundResource(0);

                     }
                   });
             viewHolder.video.setOnInfoListener(new OnInfoListener() {
                      @Override
                       public boolean onInfo(final MediaPlayer mp, final int what, int extra) {
                         // TODO Auto-generated method stub
                         Log.d("BUFFRRING START", "On_InFO");
                         new Handler().postDelayed(new Runnable() {

                             @Override
                             public void run() {
                         if (MediaPlayer.MEDIA_INFO_BUFFERING_START == what) {
                               viewHolder.progressbar.setVisibility(View.VISIBLE);
                             Log.d("BUFFRRING START", "" + what);
                         }
                         if (MediaPlayer.MEDIA_INFO_BUFFERING_END == what) {
                               viewHolder.progressbar.setVisibility(View.GONE);
                               Log.d("BUFFRRING END", "" + what);
                         }
                         if (MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START == what) {
                               viewHolder.progressbar.setVisibility(View.GONE);

                               Log.d("RENDERING END", "" + what);
                         }
                             }
                        }, 100);
                         return false;
                       }
                   });
              viewHolder.video.setOnErrorListener(new OnErrorListener() {

                       @Override
                       public boolean onError(MediaPlayer mp, int what, int extra) {
                           // TODO Auto-generated method stub

                           Log.d("Error", "------>error" + what + "/" + extra);
                           if (extra != 0) {
                               Toast.makeText(MainActivity.this, "Can't Play Video",
                                       Toast.LENGTH_SHORT).show();
                           }

                           return false;
                       }
                   });
              viewHolder.video.clearAnimation();
              return convertView;           
        }

    }
}

manifeast.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.videoviewexample"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="21" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.STORAGE" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I am getting error (1, -2147483648) how I resolve this?In solution I found that it is version problem but I am not able to solve it please guide me what is the real issue?

Logcat:

07-25 15:22:54.181: D/dalvikvm(6785): GC_FOR_ALLOC freed 44K, 69% free 3558K/11248K, paused 13ms, total 14ms
07-25 15:22:54.181: I/dalvikvm-heap(6785): Grow heap (frag case) to 4.931MB for 864016-byte allocation
07-25 15:22:54.411: D/in getview method:(6785): 3
07-25 15:22:54.411: D/current item position:(6785): 0
07-25 15:22:54.421: D/video url inadapter:(6785): [http://journey.coderspreview.com/uploads/Home_Video/mov_bbb.mp4, http://journey.coderspreview.com/uploads/experience/165/video/father-and-young-daughter.mp4, http://journey.coderspreview.com/uploads/experience/185/video/couple-on-sail-boat.mp4, http://journey.coderspreview.com/uploads/experience/39/video/VID-20141231-WA0006.mp4, http://journey.coderspreview.com/uploads/experience/26/video/VID-20141216-WA0004.mp4]
07-25 15:22:54.541: E/MediaPlayer-JNI(6785): QCMediaPlayer mediaplayer NOT present
07-25 15:22:54.541: D/MediaPlayer(6785): Couldn't open file on client side, trying server side
07-25 15:22:54.871: D/dalvikvm(6785): GC_FOR_ALLOC freed 854K, 69% free 3567K/11248K, paused 7ms, total 8ms
07-25 15:22:54.871: I/dalvikvm-heap(6785): Grow heap (frag case) to 4.939MB for 864016-byte allocation
07-25 15:22:55.991: D/dalvikvm(6785): GC_FOR_ALLOC freed 844K, 69% free 3566K/11248K, paused 13ms, total 13ms
07-25 15:22:55.991: I/dalvikvm-heap(6785): Grow heap (frag case) to 4.939MB for 864016-byte allocation
07-25 15:22:58.221: E/MediaPlayer(6785): error (1, -2147483648)
07-25 15:23:07.501: I/dalvikvm(6785): threadid=3: reacting to signal 3
07-25 15:23:07.531: I/dalvikvm(6785): Wrote stack traces to '/data/anr/traces.txt'
07-25 15:23:11.311: A/libc(6785): Fatal signal 6 (SIGABRT) at 0x0000031f (code=0), thread 6785 (ideoviewexample)
android
media-player
asked on Stack Overflow Jul 25, 2015 by Nidhi Dave • edited Jul 25, 2015 by Calcolat

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0