Share via


Windows Media Player 11 SDK Retrieving Status Information 

Windows Media Player SDK banner art

Previous Next

Retrieving Status Information

Status information is updated using the timer created in the Init function. All status is updated using the same timer. The name of the function for the timer event is OnTimer.

OnTimer determines the information to display based upon the user selection, which is stored in the global variable named g_oCurrentDLItem. The function first tests whether the size or progress values are valid and creates a string for each case.

var Size = g_oCurrentDLItem.size <=0 ? "Waiting..." : g_oCurrentDLItem.size + " bytes";
var Progress = g_oCurrentDLItem.progress <=0 ? "Waiting..." : g_oCurrentDLItem.progress + " bytes";

If a value is valid, the string represents the byte count. If the value is not valid, such as -1, the string provides a message to inform the user that the information is not yet available.

Next, a switch block determines whether the download for the selected item is completed or canceled. If either case is true, the value of the variables Size or Progress is updated accordingly.

switch(g_oCurrentDLItem.downloadState)
{
    case 3:            
        Size = "Completed";
        Progress = "Completed";
        break;
        
    case 4:
        Size = "Canceled";
        Progress = "Canceled";
        break;
        
    default:
        break;                
}

Finally, the status information is displayed in the DIV element named dlstate.

See Also

Previous Next