Skip to content Skip to sidebar Skip to footer

Cannot Resolve Method 'setdatasource(android.net.uri)'

Class Code: package com.example.chirag.cook; import android.app.Activity; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.vie

Solution 1:

Try this

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mp = new MediaPlayer();
        mSurfaceView = (SurfaceView) findViewById(R.id.surface);
        holder = mSurfaceView .getHolder();
        //...
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        mp.setDisplay(holder);
        Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
                + R.raw.bgvideo);
        try{
            mp.setDataSource(this,video);
            mp.prepare();
            mp.start();
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }    
    }

Post a Comment for "Cannot Resolve Method 'setdatasource(android.net.uri)'"