VLC媒体播放程序

源代码在线查看: time.cpp

软件大小: 13657 K
上传用户: moxcki
关键词: VLC 媒体 播放 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*****************************************************************************				 * time.cpp				 *****************************************************************************				 * Copyright (C) 2003 VideoLAN				 * $Id: time.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $				 *				 * Authors: Cyril Deguet     				 *          Olivier Teuli鑢e 				 *				 * This program is free software; you can redistribute it and/or modify				 * it under the terms of the GNU General Public License as published by				 * the Free Software Foundation; either version 2 of the License, or				 * (at your option) any later version.				 *				 * This program is distributed in the hope that it will be useful,				 * but WITHOUT ANY WARRANTY; without even the implied warranty of				 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the				 * GNU General Public License for more details.				 *				 * You should have received a copy of the GNU General Public License				 * along with this program; if not, write to the Free Software				 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.				 *****************************************************************************/								#include   // snprintf								#include "time.hpp"				#include 												void Time::set( float percentage, bool updateVLC )				{				    if( getIntf()->p_sys->p_input == NULL )				    {				        return;				    }								    VarPercent::set( percentage );								    // Avoid looping forever...				    if( updateVLC )				    {				        vlc_value_t pos;				        pos.f_float = percentage;								        var_Set( getIntf()->p_sys->p_input, "position", pos );				    }				}												string Time::getAsStringPercent() const				{				    int value = (int)(100. * get());				    // 0 				    char *str = new char[4];				    snprintf( str, 4, "%d", value );				    string ret = str;				    delete[] str;								    return ret;				}												string Time::getAsStringTime() const				{				    if( getIntf()->p_sys->p_input == NULL ||				        !getIntf()->p_sys->p_input->stream.b_seekable )				    {				        return "-:--:--";				    }								    vlc_value_t time;				    char *psz_time = new char[MSTRTIME_MAX_SIZE];				    var_Get( getIntf()->p_sys->p_input, "time", &time );								    int i_seconds = time.i_time / 1000000;				    snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",				              (int) (i_seconds / (60 * 60)),				              (int) (i_seconds / 60 % 60),				              (int) (i_seconds % 60) );								    string ret = psz_time;				    delete[] psz_time;								    return ret;				}							

相关资源