0

我有以下代码可以在屏幕上显示的任何内容之上显示 VideoView。

public void showVideo(float x, float y) {
    AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) video.getLayoutParams();
    params.width=190;
    params.height=240;
    params.x = (int) x;
    params.y = (int) y;

    video.requestLayout();

    video.setVisibility(View.VISIBLE);
    video.setVideoURI(Uri.parse("file://sdcard/test-edition/sample.mp4"));
    video.start();
}

(是的,这使用 AbsoluteLayout,我需要在特定位置显示它(任何其他解决方案都值得赞赏))。

“file://sdcard/test-edition/sample.mp4”的这个路径是我为测试目的下载的有效 mp4。

显示时,系统只显示“无法播放视频。发生错误。”,但 Logcat 上没有堆栈跟踪。如果它有用的话,我在尝试运行它时会有这个详细的信息:

VERBOSE/MediaPlayer-JNI(824): native_setup                                                                                                                                           
VERBOSE/MediaPlayer(824): constructor                                                                                                                                                
VERBOSE/MediaPlayer(824): setListener                                                                                                                                                
VERBOSE/MediaPlayer-JNI(824): setDataSource: path /test-edition/sample.mp4                                                                                                           
VERBOSE/MediaPlayer(824): setDataSource(/test-edition/sample.mp4)                                                                                                                    
VERBOSE/PVPlayer(2417): PVPlayer constructor                                                                                                                                         
VERBOSE/PVPlayer(2417): construct PlayerDriver                                                                                                                                       
VERBOSE/PlayerDriver(2417): constructor                                                                                                                                              
VERBOSE/PlayerDriver(2417): OpenCore hardware module not found                                                                                                                       
VERBOSE/PlayerDriver(2417): start player thread                                                                                                                                      
VERBOSE/PlayerDriver(2417): startPlayerThread                                                                                                                                        
VERBOSE/PlayerDriver(2417): InitializeForThread                                                                                                                                      
VERBOSE/PlayerDriver(2417): OMX_MasterInit                                                                                                                                           
VERBOSE/PlayerDriver(2417): OsclScheduler::Init                                                                                                                                      
VERBOSE/PlayerDriver(2417): CreatePlayer                                                                                                                                             
DEBUG/(2417): SISO TEST registering PVMFRecognizerPluginFactory                                                                                                                      
DEBUG/(2417): SISO TEST registering PVMFRecognizerPluginFactory success                                                                                                              
VERBOSE/PlayerDriver(2417): AddToScheduler                                                                                                                                           
VERBOSE/PlayerDriver(2417): PendForExec                                                                                                                                              
VERBOSE/PlayerDriver(2417): OsclActiveScheduler::Current                                                                                                                             
VERBOSE/PlayerDriver(2417): StartScheduler                                                                                                                                           
VERBOSE/PVPlayer(2417): send PLAYER_SETUP                                                                                                                                            
VERBOSE/PlayerDriver(2417): Send player code: 2                                                                                                                                      
VERBOSE/PlayerDriver(2417): CommandCompleted                                                                                                                                         
VERBOSE/PlayerDriver(2417): Completed command PLAYER_SETUP status=1                                                                                                                  
VERBOSE/PVPlayer(2417): setDataSource(/test-edition/sample.mp4)                                                                                                                      
INFO/PlayerDriver(2417): PlayerDriver::isProtectedFile(/test-edition/sample.mp4)                                                                                                     
VERBOSE/PlayerDriver(2417): File EXT is : .mp4                                                                                                                                       
ERROR/PlayerDriver(2417): PlayerDriver::it is a not Protected file                                                                                                                   
VERBOSE/MediaPlayer(824): setVideoSurface                                                                                                                                            
VERBOSE/PVPlayer(2417): setVideoSurface(0x6fd00)                                                                                                                                     
VERBOSE/MediaPlayer-JNI(824): setAudioStreamType: 3                                                                                                                                  
VERBOSE/MediaPlayer(824): MediaPlayer::setAudioStreamType                                                                                                                            
VERBOSE/MediaPlayer-JNI(824): prepareAsync: surface=0x2cae40 (id=2)                                                                                                                  
VERBOSE/MediaPlayer(824): setVideoSurface                                                                                                                                            
VERBOSE/PVPlayer(2417): setVideoSurface(0x6fd38)                                                                                                                                     
VERBOSE/MediaPlayer(824): prepareAsync                                                                                                                                               
VERBOSE/PVPlayer(2417): prepareAsync                                                                                                                                                 
VERBOSE/PVPlayer(2417):   data source = /test-edition/sample.mp4                                                                                                                     
VERBOSE/PlayerDriver(2417): Send player code: 3                                                                                                                                      
VERBOSE/PlayerDriver(2417): handleSetDataSource                                                                                                                                      
VERBOSE/PlayerDriver(2417): handleSetDataSource- scanning for extension                                                                                                              
ERROR/OsclDirectFileIO(2417): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1                                                                                     
VERBOSE/PlayerDriver(2417): HandleInformationalEvent: 26                                                                                                                             
VERBOSE/PlayerDriver(2417): HandleInformationalEvent: type=26 UNHANDLED                                                                                                              
ERROR/MediaPlayerService(2417): Client::notify In                                                                                                                                    
ERROR/MediaPlayer(824): message received msg=200, ext1=1, ext2=26                                                                                                                    
WARN/MediaPlayer(824): info/warning (1, 26)                                                                                                                                          
ERROR/MediaPlayer(824): callback application                                                                                                                                         
ERROR/MediaPlayer(824): back from callback                                                                                                                                           
VERBOSE/PlayerDriver(2417): CommandCompleted                                                                                                                                         
VERBOSE/PlayerDriver(2417): Completed command PLAYER_SET_DATA_SOURCE status=-4                                                                                                       
ERROR/PlayerDriver(2417): Command PLAYER_SET_DATA_SOURCE completed with an error or info -4                                                                                          
ERROR/MediaPlayerService(2417): Client::notify In                                                                                                                                    
ERROR/MediaPlayer(824): message received msg=100, ext1=-4, ext2=-4                                                                                                                   
ERROR/MediaPlayer(824): error (-4, -4)                                                                                                                                               
ERROR/MediaPlayer(824): callback application                                                                                                                                         
ERROR/MediaPlayer(824): back from callback                                                                                                                                           
VERBOSE/PVPlayer(2417): run_init s=-2147483648, cancelled=0                                                                                                                          
VERBOSE/PlayerDriver(2417): HandleInformationalEvent: 27                                                                                                                             
WARN/PlayerDriver(2417): PVMFInfoErrorHandlingComplete                                                                                                                               
INFO/MediaPlayer(824): Info (1,26)                                                                                                                                                   
ERROR/MediaPlayer(824): Error (-4,-4)                                                                                                                                                
DEBUG/VideoView(824): Error: -4,-4                                                                                                                                                   
4

1 回答 1

1

我解决了它:

video.setVideoPath("/sdcard/test-edition/sample.3gp");

看起来这只是一个 URI 解析器问题,但 VideoView 并没有说任何有用的东西。

于 2011-07-26T21:51:51.460 回答