0

我正在一个Android应用程序中工作Titanium。在某个屏幕上,我必须播放链接中的视频。充电需要一些时间,所以我必须放一个ProgressDialog,直到视频开始。我试着用ActivityIndicator这个,像这样:

var activeMovie = Titanium.Media.createVideoPlayer({
        backgroundColor:'#000',
        fullscreen:true
   });

   var dialog = Titanium.UI.createActivityIndicator();
    dialog.message = 'Loading...';

   win.add(dialog);
   dialog.show(); 

   activeMovie.setUrl(url);
   activeMovie.mediaControlStyle=Titanium.Media.VIDEO_CONTROL_FULLSCREEN;

   activeMovie.addEventListener("preload", function(e){
        dialog.show()  ;        
  });

   activeMovie.addEventListener('load', function(e){
        dialog.hide()  ;        
   });
   activeMovie.addEventListener('complete', function(e){
        activeMovie.stop();
        navController.close();
   });

此代码使出现ProgressDialog2 秒然后消失。在这段时间之后,我会出现一段时间的黑屏(视频正在充电),然后视频开始播放。谁能帮助我我的错误在哪里?

4

1 回答 1

3

您的问题的一种解决方案可能是:

var activeMovie = Titanium.Media.createVideoPlayer({
       url: url,
       backgroundColor:'#111',
       movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT // See TIMOB-2802, which may change this property name

    });

    win.add(activeMovie);
    var dlg = Titanium.UI.createActivityIndicator();
    win.addEventListener('open',function()
    {
           dlg.setMessage('Loading...');
           dlg.show();
    });

    activeMovie.addEventListener('load',function()
    {
           dlg.hide();
    });

    activeMovie.addEventListener('complete',function()
    {
           win.close();
    });

    activeMovie.play();

    win.addEventListener('close', function() 
    {
           windowClosed = true;
           activeMovie.stop();
    });
于 2012-03-16T13:06:36.173 回答