diff --git a/pandaapp/src/indexify/indexImage.cxx b/pandaapp/src/indexify/indexImage.cxx index 54f12f580a..150eb99b9c 100644 --- a/pandaapp/src/indexify/indexImage.cxx +++ b/pandaapp/src/indexify/indexImage.cxx @@ -621,8 +621,41 @@ generate_reduced_html(ostream &html, Photo *photo, int photo_index, int pi, Filename movie_icon_href = compose_href("../..", movie_icon); html << "\"\""; } - html - << "Play movie

\n"; + + // Determine the size of the file. + streampos size = 0; + ifstream stream; + Filename movie_filename(_dir->get_dir(), photo->get_movie()); + movie_filename.set_binary(); + if (movie_filename.open_read(stream)) { + // Seek to the end and get the stream position there. + stream.seekg(0, ios::end); + size = stream.tellg(); + } + + static const streampos MB = 1024 * 1024; + static const streampos GB = 1024 * 1024 * 1024; + string size_units; + double size_float; + + if (size > GB) { + size_units = "GB"; + size_float = (double)size / (double)GB; + } else if (size > MB) { + size_units = "MB"; + size_float = (double)size / (double)MB; + } + + if (size_units.empty()) { + html + << "Play movie

\n"; + } else { + char buffer[128]; + sprintf(buffer, "%.1f", size_float); + html + << "Play movie (" + << buffer << " " << size_units << ")

\n"; + } } generate_nav_buttons(html, prev_photo_filename, next_photo_filename,