开发者

Android simplest VideoView sample can't run

public class Tvdiplay1 extends Activity {      
    public void onCreate(Bundle savedInstanceState) 
    {          
        super.onCreate(savedInstanceState);           
        setContentView(R.layout.tvdisplay);           
        VideoView videoView = (VideoView) findViewById(R.id.tvvideoView);          
        MediaController mediaController = new MediaC开发者_如何学编程ontroller(this);          
        mediaController.setAnchorView(videoView);          
        Uri video = Uri.parse("android-resource://" + R.raw.movie);          
        videoView.setMediaController(mediaController);          
        videoView.setVideoURI(video);          
        videoView.start(); 
    } 
} 

The screen displays "Sorry the video cannot be played", after checking the movie in the device - it works in other players I can only imagine that the problem is in the path.

Currently it has problems with R.raw.movie which isn't recognized by the compiler although it was generated in the R class file. I can see the constant, i just can use it.

I'm really clueless about this problem, so please help !


Context.getPackageName() in the path will help you!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜