perrykm / yoyoplayer

Automatically exported from code.google.com/p/yoyoplayer
0 stars 1 forks source link

yoyoplayer文件无法打开时的处理优化 #59

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
暑假空闲时间比较多,认真的看了一下代码。发现当播放列��
�里面的文件已经不再存在时(文件被删除、或者文件被移动�
��,yoyoplayer就停在那个地方了。参考ttplayer的处理方式,我觉
得这种情况下应该跳到下一首歌继续播放,而不应该停在那��
�地方。

我做了以下修改,让SongInfoPanel可以临时的显示一些提示性信�
��,为此,增加了
    private boolean hasOtherMsg = false;
    private String otherMsg;
两个字段,和
    public synchronized void setOtherMsg(String msg)
    public synchronized void clearOtherMsg( )
    public synchronized String getOtherMsg()
三个方法,同时,对paintComponent方法做了以下修改。
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.WHITE);
        String s = getOtherMsg();
        if(s != null){
            Util.drawString(g, s, x1, y1);
            Util.drawString(g, s, x2, y2);
            length = Util.getStringWidth(s, g);
        }else{
            Util.drawString(g, preShow, x1, y1);
            Util.drawString(g, show, x2, y2);
            length = Util.getStringWidth(show, g);
        }        

    }
利用修改过的SongInfoPanel,PlayerUI:processPlay方法中增加以下对
BasicPlayerException 异常的处理
catch (BasicPlayerException bpe) {
      showMessage(Config.getResource("title.invalidfile"));                 
log.log(Level.INFO, Config.getResource("title.invalidfile"));
infoPanel.setOtherMsg(Config.getResource("title.invalidfile"));

try{
    Thread.currentThread().sleep(10000);
}catch(InterruptedException e){
    e.printStackTrace();
}
infoPanel.clearOtherMsg();

playerState = PLAY;
next.doClick();
return;                 
} 

Original issue reported on code.google.com by hellog...@gmail.com on 17 Aug 2010 at 3:29

Attachments: