| | 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 ); |
|---|
| | 838 | |
|---|
| 844 | | /* load icons */ |
|---|
| 845 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/play.xpm", |
|---|
| 846 | | &p_playIcon, NULL, NULL); |
|---|
| 847 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/pause.xpm", |
|---|
| 848 | | &p_pauseIcon, NULL, NULL); |
|---|
| 849 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/stop.xpm", |
|---|
| 850 | | &p_stopIcon, NULL, NULL ); |
|---|
| 851 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_line.xpm", |
|---|
| 852 | | &p_timeline, NULL, NULL); |
|---|
| 853 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/time_icon.xpm", |
|---|
| 854 | | &p_timeKnob, NULL, NULL); |
|---|
| 855 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/fullscreen.xpm", |
|---|
| 856 | | &p_fscreen, NULL, NULL); |
|---|
| 857 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_max.xpm", |
|---|
| 858 | | &p_muteIcon, NULL, NULL); |
|---|
| 859 | | XpmReadFileToImage( p_display, DATA_PATH "/mozilla/volume_mute.xpm", |
|---|
| 860 | | &p_unmuteIcon, NULL, NULL); |
|---|
| 861 | | |
|---|
| 862 | | #if 1 /* DEBUG */ |
|---|
| 863 | | if( !p_playIcon ) |
|---|
| 864 | | { |
|---|
| 865 | | fprintf(stderr, "Error: playImage not found\n"); |
|---|
| 866 | | } |
|---|
| 867 | | if( !p_pauseIcon ) |
|---|
| 868 | | { |
|---|
| 869 | | fprintf(stderr, "Error: pauseImage not found\n"); |
|---|
| 870 | | } |
|---|
| 871 | | if( !p_stopIcon ) |
|---|
| 872 | | { |
|---|
| 873 | | fprintf(stderr, "Error: stopImage not found\n"); |
|---|
| 874 | | } |
|---|
| 875 | | if( !p_timeline ) |
|---|
| 876 | | { |
|---|
| 877 | | fprintf(stderr, "Error: TimeLineImage not found\n"); |
|---|
| 878 | | } |
|---|
| 879 | | if( !p_timeKnob ) |
|---|
| 880 | | { |
|---|
| 881 | | fprintf(stderr, "Error: TimeIcon not found\n"); |
|---|
| 882 | | } |
|---|
| 883 | | if( !p_fscreen ) |
|---|
| 884 | | { |
|---|
| 885 | | fprintf(stderr, "Error: FullscreenImage not found\n"); |
|---|
| 886 | | } |
|---|
| 887 | | if( !p_muteIcon ) |
|---|
| 888 | | { |
|---|
| 889 | | fprintf(stderr, "Error: MuteImage not found\n"); |
|---|
| 890 | | } |
|---|
| 891 | | if( !p_unmuteIcon ) |
|---|
| 892 | | { |
|---|
| 893 | | fprintf(stderr, "Error: UnMuteImage not found\n"); |
|---|
| 894 | | } |
|---|
| 895 | | #endif |
|---|
| 896 | | |
|---|
| 898 | | if( p_pauseIcon && (i_playing == 1) ) |
|---|
| 899 | | { |
|---|
| 900 | | XPutImage( p_display, control, gc, p_pauseIcon, 0, 0, 4, 14, |
|---|
| 901 | | p_pauseIcon->width, p_pauseIcon->height ); |
|---|
| 902 | | } |
|---|
| 903 | | else if( p_playIcon ) |
|---|
| 904 | | { |
|---|
| 905 | | XPutImage( p_display, control, gc, p_playIcon, 0, 0, 4, 14, |
|---|
| 906 | | p_playIcon->width, p_playIcon->height ); |
|---|
| 907 | | } |
|---|
| 908 | | |
|---|
| 909 | | if( p_stopIcon ) |
|---|
| 910 | | XPutImage( p_display, control, gc, p_stopIcon, 0, 0, 39, 14, |
|---|
| 911 | | p_stopIcon->width, p_stopIcon->height ); |
|---|
| 912 | | if( p_fscreen ) |
|---|
| 913 | | XPutImage( p_display, control, gc, p_fscreen, 0, 0, 67, 21, |
|---|
| 914 | | p_fscreen->width, p_fscreen->height ); |
|---|
| 915 | | |
|---|
| 916 | | if( p_unmuteIcon && b_mute ) |
|---|
| 917 | | { |
|---|
| 918 | | XPutImage( p_display, control, gc, p_unmuteIcon, 0, 0, 94, 30, |
|---|
| 919 | | p_unmuteIcon->width, p_unmuteIcon->height ); |
|---|
| 920 | | } |
|---|
| 921 | | else if( p_muteIcon ) |
|---|
| 922 | | { |
|---|
| 923 | | XPutImage( p_display, control, gc, p_muteIcon, 0, 0, 94, 30, |
|---|
| 924 | | p_muteIcon->width, p_muteIcon->height ); |
|---|
| | 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 ); |
|---|
| 938 | | if( p_playIcon ) XDestroyImage( p_playIcon ); |
|---|
| 939 | | if( p_pauseIcon ) XDestroyImage( p_pauseIcon ); |
|---|
| 940 | | if( p_stopIcon ) XDestroyImage( p_stopIcon ); |
|---|
| 941 | | if( p_timeline ) XDestroyImage( p_timeline ); |
|---|
| 942 | | if( p_timeKnob ) XDestroyImage( p_timeKnob ); |
|---|
| 943 | | if( p_fscreen ) XDestroyImage( p_fscreen ); |
|---|
| 944 | | if( p_muteIcon ) XDestroyImage( p_muteIcon ); |
|---|
| 945 | | if( p_unmuteIcon ) XDestroyImage( p_unmuteIcon ); |
|---|
| | 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 ); |
|---|
| 974 | | f_length = (float)f_length * |
|---|
| 975 | | ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) ); |
|---|
| 976 | | |
|---|
| 977 | | libvlc_exception_init( &ex ); |
|---|
| 978 | | libvlc_media_instance_set_time( p_md, f_length, &ex ); |
|---|
| 979 | | libvlc_exception_clear( &ex ); |
|---|
| 980 | | } |
|---|
| 981 | | |
|---|
| 982 | | /* play/pause toggle */ |
|---|
| 983 | | if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) ) |
|---|
| 984 | | { |
|---|
| 985 | | int i_playing; |
|---|
| 986 | | libvlc_exception_init( &ex ); |
|---|
| 987 | | i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); |
|---|
| 988 | | libvlc_exception_clear( &ex ); |
|---|
| 989 | | |
|---|
| 990 | | libvlc_exception_init( &ex ); |
|---|
| 991 | | if( i_playing == 1 ) |
|---|
| 992 | | libvlc_playlist_pause( p_plugin->getVLC(), &ex ); |
|---|
| 993 | | else |
|---|
| 994 | | libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex ); |
|---|
| 995 | | libvlc_exception_clear( &ex ); |
|---|
| 996 | | } |
|---|
| 997 | | |
|---|
| 998 | | /* stop */ |
|---|
| 999 | | if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) ) |
|---|
| 1000 | | { |
|---|
| 1001 | | libvlc_exception_init( &ex ); |
|---|
| 1002 | | libvlc_playlist_stop( p_plugin->getVLC(), &ex ); |
|---|
| 1003 | | libvlc_exception_clear( &ex ); |
|---|
| 1004 | | } |
|---|
| 1005 | | |
|---|
| 1006 | | /* fullscreen */ |
|---|
| 1007 | | if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) ) |
|---|
| 1008 | | { |
|---|
| 1009 | | libvlc_exception_init( &ex ); |
|---|
| 1010 | | libvlc_set_fullscreen( p_md, 1, &ex ); |
|---|
| 1011 | | libvlc_exception_clear( &ex ); |
|---|
| 1012 | | } |
|---|
| 1013 | | |
|---|
| 1014 | | /* mute toggle */ |
|---|
| 1015 | | if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109)) |
|---|
| 1016 | | { |
|---|
| 1017 | | libvlc_exception_init( &ex ); |
|---|
| 1018 | | libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); |
|---|
| 1019 | | libvlc_exception_clear( &ex ); |
|---|
| 1020 | | } |
|---|
| 1021 | | libvlc_media_instance_release( p_md ); |
|---|
| 1022 | | |
|---|
| | 959 | /* jump in the movie */ |
|---|
| | 960 | if( i_yPos <= (i_height-30) ) |
|---|
| | 961 | { |
|---|
| | 962 | vlc_int64_t f_length; |
|---|
| | 963 | libvlc_exception_init( &ex ); |
|---|
| | 964 | f_length = libvlc_media_instance_get_length( p_md, &ex ) / 100; |
|---|
| | 965 | libvlc_exception_clear( &ex ); |
|---|
| | 966 | |
|---|
| | 967 | f_length = (float)f_length * |
|---|
| | 968 | ( ((float)i_xPos-4 ) / ( ((float)i_width-8)/100) ); |
|---|
| | 969 | |
|---|
| | 970 | libvlc_exception_init( &ex ); |
|---|
| | 971 | libvlc_media_instance_set_time( p_md, f_length, &ex ); |
|---|
| | 972 | libvlc_exception_clear( &ex ); |
|---|
| | 973 | } |
|---|
| | 974 | |
|---|
| | 975 | /* play/pause toggle */ |
|---|
| | 976 | if( (i_yPos > (i_height-30)) && (i_xPos > 4) && (i_xPos <= 39) ) |
|---|
| | 977 | { |
|---|
| | 978 | int i_playing; |
|---|
| | 979 | libvlc_exception_init( &ex ); |
|---|
| | 980 | i_playing = libvlc_playlist_isplaying( p_plugin->getVLC(), &ex ); |
|---|
| | 981 | libvlc_exception_clear( &ex ); |
|---|
| | 982 | |
|---|
| | 983 | libvlc_exception_init( &ex ); |
|---|
| | 984 | if( i_playing == 1 ) |
|---|
| | 985 | libvlc_playlist_pause( p_plugin->getVLC(), &ex ); |
|---|
| | 986 | else |
|---|
| | 987 | libvlc_playlist_play( p_plugin->getVLC(), -1, 0, NULL, &ex ); |
|---|
| | 988 | libvlc_exception_clear( &ex ); |
|---|
| | 989 | } |
|---|
| | 990 | |
|---|
| | 991 | /* stop */ |
|---|
| | 992 | if( (i_yPos > (i_height-30)) && (i_xPos > 39) && (i_xPos < 67) ) |
|---|
| | 993 | { |
|---|
| | 994 | libvlc_exception_init( &ex ); |
|---|
| | 995 | libvlc_playlist_stop( p_plugin->getVLC(), &ex ); |
|---|
| | 996 | libvlc_exception_clear( &ex ); |
|---|
| | 997 | } |
|---|
| | 998 | |
|---|
| | 999 | /* fullscreen */ |
|---|
| | 1000 | if( (i_yPos > (i_height-30)) && (i_xPos >= 67) && (i_xPos < 94) ) |
|---|
| | 1001 | { |
|---|
| | 1002 | libvlc_exception_init( &ex ); |
|---|
| | 1003 | libvlc_set_fullscreen( p_md, 1, &ex ); |
|---|
| | 1004 | libvlc_exception_clear( &ex ); |
|---|
| | 1005 | } |
|---|
| | 1006 | |
|---|
| | 1007 | /* mute toggle */ |
|---|
| | 1008 | if( (i_yPos > (i_height-30)) && (i_xPos >= 94) && (i_xPos < 109)) |
|---|
| | 1009 | { |
|---|
| | 1010 | libvlc_exception_init( &ex ); |
|---|
| | 1011 | libvlc_audio_toggle_mute( p_plugin->getVLC(), &ex ); |
|---|
| | 1012 | libvlc_exception_clear( &ex ); |
|---|
| | 1013 | } |
|---|
| | 1014 | libvlc_media_instance_release( p_md ); |
|---|
| | 1015 | } |
|---|