来自《sencha touch权威指南》第10章,315页开始

app.js代码如下:

Ext.require(['Ext.Video','Ext.MessageBox','Ext.Toolbar','Ext.Panel']);
Ext.application({
    name: 'MyApp',
    icon: 'images/icon.png',
    glossOnIcon: false,
    phoneStartupScreen: 'images/phone_startup.png',
    tabletStartupScreen: 'images/tablet_startup.png',
    
    launch: function(){
        var video = Ext.create('Ext.Video',{
            fullScreen: false,
            width: '300',
            height: '200',
            url: 'images/music.mp4',
            enableControls: true,
            loop: true,
            listeners: {
                play: function(){
                    button.setDisabled(false);
                    button.setText("暂停");
                },
                ended: function(){
                    button.setText('播放');
                }
            }
        });

        var videoPlayOrPause = function(){
            if(button.getText() == "暂停"){
                video.pause();
                button.setText("播放");
            }else{
                video.play();
                button.getText("暂停");
            }
        }

        var button = Ext.create('Ext.Button',{
            id: 'playButton',
            text: '播放',
            disabled: true,
            handler: videoPlayOrPause
        });

        var toolbar = new Ext.Toolbar({
            docked: 'top',
            items: button
        });

        var panel = Ext.create('Ext.Panel',{
            layout: 'vbox',
            items: [toolbar,video]
        });

        Ext.Viewport.add(panel);
    }
});

 

相关文章:

  • 2021-03-28
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-12-29
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
相关资源
相似解决方案