Changeset 35979e860abf629200c6946d0d24b58a33b435f5
- Timestamp:
- 02/25/08 10:22:36 (6 months ago)
- git-parent:
- Files:
-
- projects/mozilla/vlcplugin.cpp (modified) (2 diffs)
- projects/mozilla/vlcplugin.h (modified) (3 diffs)
- projects/mozilla/vlcshell.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/mozilla/vlcplugin.cpp
rf90b88a r35979e8 58 58 ,i_width((unsigned)-1) 59 59 ,i_height((unsigned)-1) 60 ,i_last_position(0) 60 61 #endif 61 62 { … … 444 445 return diff; 445 446 } 447 448 void VlcPlugin::showToolbar() 449 { 450 const NPWindow& window = getWindow(); 451 Window control = getControlWindow(); 452 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; 453 454 /* load icons */ 455 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm", 456 &p_btnPlay, NULL, NULL); 457 if( p_btnPlay ) 458 i_control_height = __MAX( i_control_height, p_btnPlay->height ); 459 460 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm", 461 &p_btnPause, NULL, NULL); 462 if( p_btnPause ) 463 i_control_height = __MAX( i_control_height, p_btnPause->height ); 464 465 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm", 466 &p_btnStop, NULL, NULL ); 467 if( p_btnStop ) 468 i_control_height = __MAX( i_control_height, p_btnStop->height ); 469 470 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm", 471 &p_timeline, NULL, NULL); 472 if( p_timeline ) 473 i_control_height = __MAX( i_control_height, p_timeline->height ); 474 475 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm", 476 &p_btnTime, NULL, NULL); 477 if( p_btnTime ) 478 i_control_height = __MAX( i_control_height, p_btnTime->height ); 479 480 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm", 481 &p_btnFullscreen, NULL, NULL); 482 if( p_btnFullscreen ) 483 i_control_height = __MAX( i_control_height, p_btnFullscreen->height); 484 485 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm", 486 &p_btnMute, NULL, NULL); 487 if( p_btnMute ) 488 i_control_height = __MAX( i_control_height, p_btnMute->height); 489 490 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm", 491 &p_btnUnmute, NULL, NULL); 492 if( p_btnUnmute ) 493 i_control_height = __MAX( i_control_height, p_btnUnmute->height); 494 495 if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline || 496 !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute ) 497 fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH ); 498 } 499 500 void VlcPlugin::hideToolbar() 501 { 502 if( p_btnPlay ) XDestroyImage( p_btnPlay ); 503 if( p_btnPause ) XDestroyImage( p_btnPause ); 504 if( p_btnStop ) XDestroyImage( p_btnStop ); 505 if( p_timeline ) XDestroyImage( p_timeline ); 506 if( p_btnTime ) XDestroyImage( p_btnTime ); 507 if( p_btnFullscreen ) XDestroyImage( p_btnFullscreen ); 508 if( p_btnMute ) XDestroyImage( p_btnMute ); 509 if( p_btnUnmute ) XDestroyImage( p_btnUnmute ); 510 511 p_btnPlay = NULL; 512 p_btnPause = NULL; 513 p_btnStop = NULL; 514 p_timeline = NULL; 515 p_btnTime = NULL; 516 p_btnFullscreen = NULL; 517 p_btnMute = NULL; 518 p_btnUnmute = NULL; 519 } 520 521 void VlcPlugin::redrawToolbar() 522 { 523 libvlc_media_instance_t *p_md = NULL; 524 libvlc_exception_t ex; 525 float f_position = 0.0; 526 int i_playing = 0; 527 bool b_mute = false; 528 529 GC gc; 530 XGCValues gcv; 531 532 const NPWindow& window = getWindow(); 533 Window control = getControlWindow(); 534 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; 535 536 /* get media instance */ 537 libvlc_exception_init( &ex ); 538 p_md = libvlc_playlist_get_media_instance( getVLC(), &ex ); 539 libvlc_exception_clear( &ex ); 540 541 /* get isplaying */ 542 libvlc_exception_init( &ex ); 543 i_playing = libvlc_playlist_isplaying( getVLC(), &ex ); 544 libvlc_exception_clear( &ex ); 545 546 /* get mute info */ 547 libvlc_exception_init(&ex); 548 b_mute = libvlc_audio_get_mute( getVLC(), &ex ); 549 libvlc_exception_clear( &ex ); 550 551 /* get movie position in % */ 552 if( i_playing == 1 ) 553 { 554 libvlc_exception_init( &ex ); 555 f_position = libvlc_media_instance_get_position( p_md, &ex ) * 100; 556 libvlc_exception_clear( &ex ); 557 } 558 libvlc_media_instance_release( p_md ); 559 560 gcv.foreground = BlackPixel( p_display, 0 ); 561 gc = XCreateGC( p_display, control, GCForeground, &gcv ); 562 563 XFillRectangle( p_display, control, gc, 564 0, 0, window.width, i_control_height ); 565 gcv.foreground = WhitePixel( p_display, 0 ); 566 XChangeGC( p_display, gc, GCForeground, &gcv ); 567 568 /* position icons */ 569 fprintf( stderr, ">>>>>> is playing = %d\n", i_playing ); 570 if( p_btnPause && (i_playing == 1) ) 571 { 572 XPutImage( p_display, control, gc, p_btnPause, 0, 0, 4, 14, 573 p_btnPause->width, p_btnPause->height ); 574 } 575 else if( p_btnPlay ) 576 { 577 XPutImage( p_display, control, gc, p_btnPlay, 0, 0, 4, 14, 578 p_btnPlay->width, p_btnPlay->height ); 579 } 580 581 if( p_btnStop ) 582 XPutImage( p_display, control, gc, p_btnStop, 0, 0, 39, 14, 583 p_btnStop->width, p_btnStop->height ); 584 if( p_btnFullscreen ) 585 XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, 67, 21, 586 p_btnFullscreen->width, p_btnFullscreen->height ); 587 588 if( p_btnUnmute && b_mute ) 589 { 590 XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, 94, 30, 591 p_btnUnmute->width, p_btnUnmute->height ); 592 } 593 else if( p_btnMute ) 594 { 595 XPutImage( p_display, control, gc, p_btnMute, 0, 0, 94, 30, 596 p_btnMute->width, p_btnMute->height ); 597 } 598 599 if( p_timeline ) 600 XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4, 601 (window.width-8), p_timeline->height ); 602 603 if( f_position > 0 ) 604 i_last_position = (((float)window.width-8.0)/100.0)*f_position; 605 if( p_btnTime ) 606 XPutImage( p_display, control, gc, p_btnTime, 607 0, 0, (4+i_last_position), 2, 608 p_btnTime->width, p_btnTime->height ); 609 610 XFreeGC( p_display, gc ); 611 } 446 612 #endif 447 projects/mozilla/vlcplugin.h
rf90b88a r35979e8 54 54 # include <X11/StringDefs.h> 55 55 # include <X11/X.h> 56 57 # ifndef __APPLE__ 58 # include <X11/xpm.h> 59 # endif 60 #endif 61 62 #ifndef __MAX 63 # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) 64 #endif 65 #ifndef __MIN 66 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) 56 67 #endif 57 68 … … 97 108 void setControlWindow(Window window) 98 109 { npcontrol = window; }; 110 111 void showToolbar(); 112 void hideToolbar(); 113 void redrawToolbar(); 99 114 #endif 100 115 … … 129 144 Window npvideo, npcontrol; 130 145 146 XImage *p_btnPlay; 147 XImage *p_btnPause; 148 XImage *p_btnStop; 149 XImage *p_timeline; 150 XImage *p_btnTime; 151 XImage *p_btnFullscreen; 152 XImage *p_btnMute; 153 XImage *p_btnUnmute; 154 155 int i_last_position; 131 156 #endif 132 157 }; projects/mozilla/vlcshell.cpp
rcd2efd3 r35979e8 36 36 #endif 37 37 38 #ifdef XP_UNIX39 #ifndef __APPLE__40 #include <X11/xpm.h>41 #endif42 #endif43 44 38 /* This is from mozilla java, do we really need it? */ 45 39 #if 0 … … 53 47 54 48 #define WINDOW_TEXT "Video is loading..." 55 56 #ifndef __MAX57 # define __MAX(a, b) ( ((a) > (b)) ? (a) : (b) )58 #endif59 #ifndef __MIN60 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) )61 #endif62 49 63 50 /***************************************************************************** … … 780 767 XGCValues gcv; 781 768 782 /* Toolbar */783 XImage *p_btnPlay = NULL;784 XImage *p_btnPause = NULL;785 XImage *p_btnStop = NULL;786 XImage *p_timeline = NULL;787 XImage *p_btnTime = NULL;788 XImage *p_btnFullscreen = NULL;789 XImage *p_btnMute = NULL;790 XImage *p_btnUnmute = NULL;791 792 libvlc_media_instance_t *p_md = NULL;793 float f_position = 0;794 int i_playing = 0;795 bool b_mute = false;796 797 769 Window video = p_plugin->getVideoWindow(); 798 Window control = p_plugin->getControlWindow();799 770 Display *p_display = ((NPSetWindowCallbackStruct *)window.ws_info)->display; 800 771 801 /* load icons */ 802 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm", 803 &p_btnPlay, NULL, NULL); 804 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 805 p_btnPlay->height ); 806 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm", 807 &p_btnPause, NULL, NULL); 808 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 809 p_btnPause->height ); 810 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm", 811 &p_btnStop, NULL, NULL ); 812 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 813 p_btnStop->height ); 814 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm", 815 &p_timeline, NULL, NULL); 816 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 817 p_timeline->height ); 818 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm", 819 &p_btnTime, NULL, NULL); 820 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 821 p_btnTime->height ); 822 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm", 823 &p_btnFullscreen, NULL, NULL); 824 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 825 p_btnFullscreen->height); 826 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm", 827 &p_btnMute, NULL, NULL); 828 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 829 p_btnMute->height); 830 XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm", 831 &p_btnUnmute, NULL, NULL); 832 p_plugin->i_control_height = __MAX( p_plugin->i_control_height, 833 p_btnUnmute->height); 834 835 if( !p_btnPlay || !p_btnPause || !p_btnStop || !p_timeline || 836 !p_btnTime || !p_btnFullscreen || !p_btnMute || !p_btnUnmute ) 837 fprintf(stderr, "Error: some button images not found in %s\n", DATA_PATH ); 772 p_plugin->showToolbar(); 838 773 839 774 gcv.foreground = BlackPixel( p_display, 0 ); … … 849 784 window.width / 2 - 40, (window.height - p_plugin->i_control_height) / 2, 850 785 WINDOW_TEXT, strlen(WINDOW_TEXT) ); 851 852 /* RedrawToolbar */853 gcv.foreground = BlackPixel( p_display, 0 );854 gc = XCreateGC( p_display, control, GCForeground, &gcv );855 856 XFillRectangle( p_display, control, gc,857 0, 0, window.width, p_plugin->i_control_height );858 859 860 gcv.foreground = WhitePixel( p_display, 0 );861 XChangeGC( p_display, gc, GCForeground, &gcv );862 863 /* get media instance */864 libvlc_exception_t ex;865 libvlc_exception_init( &ex );866 p_md = libvlc_playlist_get_media_instance( p_plugin->getVLC(), &ex );867 libvlc_exception_clear( &ex );868 869 /* get isplaying */870 libvlc_exception_init( &ex );871 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex );872 libvlc_exception_clear( &ex );873 874 /* get mute info */875 libvlc_exception_init(&ex);876 b_mute = libvlc_audio_get_mute( p_plugin->getVLC(), &ex );877 libvlc_exception_clear( &ex );878 879 /* get movie position in % */880 if( i_playing == 1 )881 {882 libvlc_exception_init( &ex );883 f_position = libvlc_media_instance_get_position(p_md, &ex)*100;884 libvlc_exception_clear( &ex );885 }886 libvlc_media_instance_release(p_md);887 888 /* position icons */889 if( p_btnPause && (i_playing == 1) )890 {891 XPutImage( p_display, control, gc, p_btnPause, 0, 0, 4, 14,892 p_btnPause->width, p_btnPause->height );893 }894 else if( p_btnPlay )895 {896 XPutImage( p_display, control, gc, p_btnPlay, 0, 0, 4, 14,897 p_btnPlay->width, p_btnPlay->height );898 }899 900 if( p_btnStop )901 XPutImage( p_display, control, gc, p_btnStop, 0, 0, 39, 14,902 p_btnStop->width, p_btnStop->height );903 if( p_btnFullscreen )904 XPutImage( p_display, control, gc, p_btnFullscreen, 0, 0, 67, 21,905 p_btnFullscreen->width, p_btnFullscreen->height );906 907 if( p_btnUnmute && b_mute )908 {909 XPutImage( p_display, control, gc, p_btnUnmute, 0, 0, 94, 30,910 p_btnUnmute->width, p_btnUnmute->height );911 }912 else if( p_btnMute )913 {914 XPutImage( p_display, control, gc, p_btnMute, 0, 0, 94, 30,915 p_btnMute->width, p_btnMute->height );916 }917 918 if( p_timeline )919 XPutImage( p_display, control, gc, p_timeline, 0, 0, 4, 4,920 (window.width-8), p_timeline->height );921 if( p_btnTime && (f_position > 0) )922 {923 f_position = (((float)window.width-8)/100)*f_position;924 XPutImage( p_display, control, gc, p_btnTime, 0, 0, (4+f_position), 2,925 p_btnTime->width, p_btnTime->height );926 }927 928 /* Cleanup */929 if( p_btnPlay ) XDestroyImage( p_btnPlay );930 if( p_btnPause ) XDestroyImage( p_btnPause );931 if( p_btnStop ) XDestroyImage( p_btnStop );932 if( p_timeline ) XDestroyImage( p_timeline );933 if( p_btnTime ) XDestroyImage( p_btnTime );934 if( p_btnFullscreen ) XDestroyImage( p_btnFullscreen );935 if( p_btnMute ) XDestroyImage( p_btnMute );936 if( p_btnUnmute ) XDestroyImage( p_btnUnmute );937 938 786 XFreeGC( p_display, gc ); 787 788 p_plugin->redrawToolbar(); 789 790 p_plugin->hideToolbar(); 939 791 } 940 792
