function playbackdemo(demo_name,REL_PATH)
%PLAYBACKDEMO  Launch demo playback device
%   PLAYBACKDEMO(DEMO_NAME) launches a playback demo in "$matlabroot/demos".
%
%   PLAYBACKDEMO(DEMO_NAME,REL_PATH) specifies the relative path from matlabroot
%   to an arbitrary directory.
%
%   Example:
%      playbackdemo('desktop')

%   $Revision: 1.11.4.4 $  $Date: 2004/12/20 16:44:40 $
%   Copyright 1984-2004 The MathWorks, Inc.

% Define constants.
if (nargin < 2)
    REL_PATH = 'demos';
end
mlroot = matlabroot;

% Assemble file paths
html_file = strcat(fullfile(mlroot,REL_PATH,demo_name),'.html');

% Error out if the file doesn't exist
if exist(html_file,'file')==0
    errordlg(sprintf('Can''t find %s',html_file));
    return
end

% Convert the filename to a URL.
url = ['file:///' strrep(html_file,'\','/')];

% Launch browser
evalc('stat = web(url,''-browser'');');
if (stat==2)
   errordlg(['Could not launch Web browser. Please make sure that'  sprintf('\n') ...
   'you have enough free memory to launch the browser.']);
elseif (stat)
   errordlg(['Could not load HTML file into Web browser. Please make sure that'  sprintf('\n') ...
   'you have a Web browser properly installed on your system.']);
end
