VideoView is not displayed on a Fragment

后端 未结 3 910
走了就别回头了
走了就别回头了 2021-02-14 04:43

I have a problem in running a video in Samsung S3(Android 4.1.1), the issue seems to be because the videoview is on a fragment because if I put it on and activity, it works. Als

相关标签:
3条回答
  • 2021-02-14 05:05

    I have a similar problem, and i solved it changing:

     MediaController mediaController = new MediaController(getActivity().getApplicationContext());
    

    to this (In a fragmet):

     MediaController mediaController = new MediaController(getActivity());
    

    Hope this helps,...

    EDIT

    Look at this class

    http://code.google.com/p/sinaweibo-honeycomb/source/browse/branches/sinaweibo-merged/src/com/lenovo/dll/SinaWeibo/VideoFragment.java?r=71

    0 讨论(0)
  • 2021-02-14 05:27

    If hardware acceleration fixes your issue then I would enable it for that view/window on that device.

    In general I've found that when code works on one device but not another it is typically caused by one of the following problems:

    1. Bug in the manufacturer's API implementation
    2. Different interpretation of the API by the manufacturer
    3. Concurrency problem (e.g. race condition, improper synchronization) in your own code that happens to trigger more frequently on a particular device

    As far as I can tell you seem to be using the UI thread appropriately so I would imagine your issue falls into one of the first two categories and you'll just need to work around it.

    0 讨论(0)
  • 2021-02-14 05:31

    Move MediaController mediaController = new MediaController(getActivity()) from onResume() to onCreateView.

    0 讨论(0)
提交回复
热议问题