Changeset 227de1f76923c66c00711b6adb6721a5a325e28d
- Timestamp:
- 18/06/08 11:39:23 (6 months ago)
- git-parent:
- Files:
-
- projects/mozilla/vlcplugin.cpp (modified) (1 diff)
- projects/mozilla/vlcplugin.h (modified) (2 diffs)
- projects/mozilla/vlcshell.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/mozilla/vlcplugin.cpp
rafe32c0 r227de1f 673 673 XFreeGC( p_display, gc ); 674 674 } 675 676 vlc_toolbar_clicked_t VlcPlugin::getToolbarButtonClicked( int i_xpos, int i_ypos ) 677 { 678 unsigned int i_dest = 0; 679 int i_playing = 0; 680 bool b_mute = false; 681 libvlc_exception_t ex; 682 683 if( i_xpos >= i_tb_height ) 684 return clicked_Unknown; 685 686 /* Note: the order of testing is dependend on the original 687 * drawing positions of the icon buttons. Buttons are tested 688 * left to right. 689 */ 690 691 /* get isplaying */ 692 libvlc_exception_init( &ex ); 693 i_playing = libvlc_playlist_isplaying( getVLC(), &ex ); 694 libvlc_exception_clear( &ex ); 695 696 /* get mute info */ 697 libvlc_exception_init(&ex); 698 b_mute = libvlc_audio_get_mute( getVLC(), &ex ); 699 libvlc_exception_clear( &ex ); 700 701 702 /* is Pause of Play button clicked */ 703 if( (i_playing != 1) && 704 (i_ypos >= BTN_SPACE>>1) && 705 (i_ypos <= p_btnPlay->width + (BTN_SPACE>>1)) ) 706 return clicked_Play; 707 else if( (i_ypos >= BTN_SPACE>>1) && 708 (i_ypos <= p_btnPause->width) ) 709 return clicked_Pause; 710 711 /* is Stop button clicked */ 712 if( i_playing != 1 ) 713 i_dest += BTN_SPACE + p_btnPause->width + (BTN_SPACE>>1); 714 else 715 i_dest += BTN_SPACE + p_btnPlay->width + (BTN_SPACE>>1); 716 if( (i_ypos >= i_dest) && 717 (i_ypos <= p_btnStop->width + (BTN_SPACE>>1)) ) 718 return clicked_Stop; 719 720 /* is Fullscreen button clicked */ 721 i_dest += (p_btnStop->width + (BTN_SPACE>>1)); 722 if( (i_ypos >= i_dest) && 723 (i_ypos <= p_btnFullscreen->width + (BTN_SPACE>>1)) ) 724 return clicked_Fullscreen; 725 726 /* is Mute or Unmute button clicked */ 727 i_dest += (p_btnFullscreen->width + (BTN_SPACE>>1)); 728 if( !b_mute && (i_ypos >= i_dest) && 729 (i_ypos <= p_btnMute->width + (BTN_SPACE>>1)) ) 730 return clicked_Mute; 731 else if( (i_ypos >= i_dest) && 732 (i_ypos <= p_btnUnmute->width + (BTN_SPACE>>1)) ) 733 return clicked_Unmute; 734 735 /* is timeline clicked */ 736 if( !b_mute ) 737 i_dest += (p_btnMute->width + (BTN_SPACE>>1)); 738 else 739 i_dest += (p_btnUnmute->width + (BTN_SPACE>>1)); 740 if( (i_ypos >= i_dest) && 741 (i_ypos <= p_timeline->width + (BTN_SPACE>>1)) ) 742 return clicked_timeline; 743 744 /* is time button clicked */ 745 i_dest += (p_timeline->width + (BTN_SPACE>>1)); 746 if( (i_ypos >= i_dest) && 747 (i_ypos <= p_btnTime->width + (BTN_SPACE>>1)) ) 748 return clicked_Time; 749 750 return clicked_Unknown; 751 } 752 #undef BTN_SPACE 675 753 #endif projects/mozilla/vlcplugin.h
ref20d24 r227de1f 66 66 # define __MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) 67 67 #endif 68 69 typedef enum vlc_toolbar_clicked_e { 70 clicked_Unknown = 0, 71 clicked_Play, 72 clicked_Pause, 73 clicked_Stop, 74 clicked_timeline, 75 clicked_Time, 76 clicked_Fullscreen, 77 clicked_Mute, 78 clicked_Unmute 79 } vlc_toolbar_clicked_t; 68 80 69 81 class VlcPlugin … … 116 128 int setToolbarSize(unsigned int width, unsigned int height) 117 129 { i_tb_width = width; i_tb_height = height; return 1; }; 130 vlc_toolbar_clicked_t getToolbarButtonClicked( int i_xpos, int i_ypos ); 118 131 #endif 119 132 projects/mozilla/vlcshell.cpp
rafe32c0 r227de1f 843 843 libvlc_exception_clear( &ex ); 844 844 845 /* jump in the movie */ 846 if( i_yPos <= (i_height-30) ) 847 { 848 /* if a movie is loaded */ 849 if( p_md ) 850 { 851 int64_t f_length; 845 vlc_toolbar_clicked_t clicked; 846 clicked = p_plugin->getToolbarButtonClicked( i_xPos, i_yPos ); 847 848 switch( clicked ) 849 { 850 case clicked_Play: 851 case clicked_Pause: 852 { 853 int i_playing; 852 854 libvlc_exception_init( &ex ); 853 f_length = libvlc_media_player_get_length( p_md, &ex ) / 100;855 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); 854 856 libvlc_exception_clear( &ex ); 855 857 856 f_length = (float)f_length *857 ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) );858 859 858 libvlc_exception_init( &ex ); 860 libvlc_media_player_set_time( p_md, f_length, &ex ); 859 if( i_playing == 1 ) 860 libvlc_playlist_pause( p_plugin->getVLC(), &ex ); 861 else 862 libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex ); 861 863 libvlc_exception_clear( &ex ); 862 864 } 863 } 864 865 /* play/pause toggle */ 866 if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) ) 867 { 868 int i_playing; 869 libvlc_exception_init( &ex ); 870 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); 871 libvlc_exception_clear( &ex ); 872 873 libvlc_exception_init( &ex ); 874 if( i_playing == 1 ) 875 libvlc_playlist_pause( p_plugin->getVLC(), &ex ); 876 else 877 libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex ); 878 libvlc_exception_clear( &ex ); 879 } 880 881 /* stop */ 882 if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) ) 883 { 884 libvlc_exception_init( &ex ); 885 libvlc_playlist_stop( p_plugin->getVLC(), &ex ); 886 libvlc_exception_clear( &ex ); 887 } 888 889 /* fullscreen */ 890 if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) ) 891 { 892 int i_playing; 893 libvlc_exception_init( &ex ); 894 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); 895 libvlc_exception_clear( &ex ); 896 897 if( (i_playing == 1) && p_md ) 865 break; 866 867 case clicked_Stop: 898 868 { 899 869 libvlc_exception_init( &ex ); 900 libvlc_ set_fullscreen( p_md, 1, &ex );870 libvlc_playlist_stop( p_plugin->getVLC(), &ex ); 901 871 libvlc_exception_clear( &ex ); 902 872 } 903 } 904 905 /* mute toggle */ 906 if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109)) 907 { 908 libvlc_exception_init( &ex ); 909 libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); 910 libvlc_exception_clear( &ex ); 911 } 912 873 break; 874 875 case clicked_timeline: 876 { 877 /* if a movie is loaded */ 878 if( p_md ) 879 { 880 int64_t f_length; 881 libvlc_exception_init( &ex ); 882 f_length = libvlc_media_player_get_length( p_md, &ex ) / 100; 883 libvlc_exception_clear( &ex ); 884 885 f_length = (float)f_length * 886 ( ((float)i_xPos-4.0 ) / ( ((float)i_width-8.0)/100) ); 887 888 libvlc_exception_init( &ex ); 889 libvlc_media_player_set_time( p_md, f_length, &ex ); 890 libvlc_exception_clear( &ex ); 891 } 892 } 893 break; 894 895 case clicked_Time: 896 { 897 /* Not implemented yet*/ 898 } 899 break; 900 901 case clicked_Fullscreen: 902 { 903 int i_playing; 904 libvlc_exception_init( &ex ); 905 i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); 906 libvlc_exception_clear( &ex ); 907 908 if( (i_playing == 1) && p_md ) 909 { 910 libvlc_exception_init( &ex ); 911 libvlc_set_fullscreen( p_md, 1, &ex ); 912 libvlc_exception_clear( &ex ); 913 } 914 } 915 break; 916 917 case clicked_Mute: 918 case clicked_Unmute: 919 { 920 libvlc_exception_init( &ex ); 921 libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); 922 libvlc_exception_clear( &ex ); 923 } 924 break; 925 926 default: /* button_Unknown */ 927 break; 928 } 913 929 if( p_md ) libvlc_media_player_release( p_md ); 914 930 }
