- Timestamp:
- 2023-02-02T17:34:42+13:00 (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js
r37238 r37254 18 18 function AVPlay() 19 19 { 20 // Restore play/pause toggle button back to 'ready to play' i.e., showing pause button 20 21 $('#ws-play-icon' ).hide(); 21 22 $('#ws-pause-icon').show(); … … 387 388 }); 388 389 390 wavesurfer.on('finish', function () { 391 // auto stop RecordingUserAV 392 av_chart_record_finish(); 393 }); 394 389 395 wavesurfer.on('ready', function () { 390 396 … … 532 538 } 533 539 540 var isRecordingUserAV = false; 541 542 function crsc_popup_close($elem) 543 { 544 $elem.parents('.dialog-ovelay').fadeOut(500, function () { 545 $elem.remove(); 546 }); 547 } 548 549 function crsc_popup_cancel_callback() 550 { 551 console.log("Canceling RecordingUserAV"); 552 553 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 554 var av_context = av_canvas.getContext("2d"); 555 556 av_context.clearRect(0, 0, av_canvas.width, av_canvas.height); 557 558 crsc_popup_close($(this)); 559 560 561 if ('p_frameOffset' in gs.cgiParams) { 562 var frameOffset = gs.cgiParams['p_frameOffset']; 563 wavesurfer.seekTo(frameOffset/AMC_SONG_DURATION); 564 recommendFromPos(); 565 displayClampedCurrentTimeAndAV(); 566 } 567 else { 568 AVSeekTo(0); 569 } 570 571 } 572 573 function crsc_popup_resume_callback() 574 { 575 console.log("Resuming RecordingUserAV"); 576 isRecordingUserAV = true; 577 crsc_popup_close($(this)); 578 AVPlay(); 579 } 580 581 function crsc_popup_save_callback() 582 { 583 console.log("Saving to your browser RecordingUserAV"); 584 crsc_popup_close($(this)); 585 } 586 587 534 588 535 589 function av_chart_record_click(elem,event) 536 590 { 537 console.error("Recording mode to be implemented!") 591 if (isRecordingUserAV == false) { 592 isRecordingUserAV = true; 593 594 if (!wavesurfer.backend.isPaused()) { 595 console.log("Starting recording user's AV values"); 596 AVSeekTo(0); 597 } 598 else { 599 console.log("Resuming recording user's AV values"); 600 } 601 AVPlay() 602 } 603 else { 604 AVEnsurePaused(); 605 // Have stopped recording 606 // => Store recorded values into LocalStorage 607 isRecordingUserAV = false; 608 609 610 CancelResumeSaveConfirm('Customised AV Recording', 'Would you like to save this AV Recording?', 611 'Cancel and Start Over', 'Resume Recording', "Save", 612 crsc_popup_cancel_callback, crsc_popup_resume_callback, crsc_popup_save_callback 613 ); 614 615 } 616 } 617 618 function av_chart_record_finish(elem,event) 619 { 620 // Restore play/pause toggle button back to 'ready to play' 538 621 AVSeekTo(0); 539 AVPlayPause(); 540 if (wavesurfer.backend.isPaused()) { 541 alert("Sorry, capturing and saving of AV values not currently implemented!"); 542 } 543 } 544 622 $('#ws-play-icon' ).show(); 623 $('#ws-pause-icon').hide(); 624 $('#ws-playpause-label').html("Play"); 625 626 if (isRecordingUserAV == true) { 627 isRecordingUserAV = false; 628 629 CancelResumeSaveConfirm('Customised AV Recording', 'Would you like to save this AV Recording?', 630 'Cancel and Start Over', null, "Save", 631 crsc_popup_cancel_callback, null, crsc_popup_save_callback 632 ); 633 } 634 635 636 } 637 638 545 639 function initPlayerVisual() { 546 640 … … 581 675 582 676 $('#av-chart-img-unlabeled').hide(); 677 $('#av-chart-canvas-unlabeled').hide(); 583 678 $('#av-chart-img').show(); 679 $('#av-chart-canvas').show(); 584 680 585 681 $('#start-av-recommendation').show(); … … 603 699 // Reset what is being display to the default (the av-chart, not the record one) 604 700 $('#av-chart-img-unlabeled').hide(); 701 $('#av-chart-chart-unlabeled').hide(); 605 702 $('#av-chart-img').show(); 703 $('#av-chart-canvas').show(); 606 704 607 705 $('#start-av-recommendation').show(); … … 687 785 // Ensure it is the RecordAV chart that is shown 688 786 $('#av-chart-img').hide(); 787 $('#av-chart-canvas').hide(); 689 788 $('#av-chart-img-unlabeled').show(); 789 $('#av-chart-canvas-unlabeled').show(); 690 790 691 791 $('#start-av-recommendation').hide(); … … 707 807 function mouse_xy_to_av(elem,event,circ_x_org,circ_y_org,circ_radius) 708 808 { 709 //var circ_x_org = 183;710 //var circ_y_org = 194;711 //var circ_radius = 130;712 713 809 var relX = event.pageX - $(elem).offset().left; 714 810 var relY = event.pageY - $(elem).offset().top; … … 722 818 } 723 819 724 820 821 // Need to be very careful with order of valenceVal and arousalVal 822 // Here they are ordered to match x,y 823 824 function av_to_canvas_xy(valenceVal, arousalVal, circ_x_org,circ_y_org,circ_radius) 825 { 826 //var canvasX = (valenceVal * circ_radius) - circ_x_org; // effectively "times -1" 827 var canvasX = circ_x_org - (valenceVal * circ_radius); 828 var canvasY = circ_y_org - (arousalVal * circ_radius); 829 830 831 return { 'canvasX': canvasX, 'canvasY': canvasY }; 832 } 833 834 725 835 $(document).ready(function() { 726 836 727 console.log(`loggedInUsername = '${gs.variables.loggedInUsername}'`); 837 console.log("AV Recording now always possible, without logging in (pseudo username: mars)"); 838 gs.variables.loggedInUsername = "mars"; 839 //console.log(`loggedInUsername = '${gs.variables.loggedInUsername}'`); 728 840 if (gs.variables.loggedInUsername != "") { 841 // Logged in 729 842 $('#login-to-record-av').hide(); 730 843 $('#record-av').show(); … … 760 873 var circ_x_org = 137; 761 874 var circ_y_org = 145; 762 //var circ_radius = 234 - 137;763 875 var circ_radius = 97; 764 876 765 //var relX = event.pageX - $(this).offset().left;766 //var relY = event.pageY - $(this).offset().top;767 768 //var recValenceVal = -1 * (circ_x_org - relX) / circ_radius;769 //var recArousalVal = +1 * (circ_y_org - relY) / circ_radius;770 771 772 //var avRadius = Math.sqrt(recValenceVal*recValenceVal + recArousalVal*recArousalVal);773 774 877 var av_rec = mouse_xy_to_av(this,event,circ_x_org,circ_y_org,circ_radius); 775 878 … … 806 909 $('#av-chart-img-unlabeled').on("click",function(event) { 807 910 av_chart_record_click(this,event); 808 //console.error("Recording mode to be implemented!")809 //AVSeekTo(0);810 //AVPlayPause();811 //if (wavesurfer.backend.isPaused()) {812 // alert("Sorry, capturing and saving of AV values not currently implemented!");813 //}814 911 }); 815 912 … … 823 920 var circ_radius = 130; 824 921 825 //var relX = event.pageX - $(this).offset().left;826 //var relY = event.pageY - $(this).offset().top;827 828 //var recValenceVal = -1 * (circ_x_org - relX) / circ_radius;829 //var recArousalVal = +1 * (circ_y_org - relY) / circ_radius;830 831 832 //var avRadius = Math.sqrt(recValenceVal*recValenceVal + recArousalVal*recArousalVal);833 834 922 var av_rec = mouse_xy_to_av(this,event,circ_x_org,circ_y_org,circ_radius); 835 923 … … 847 935 $("#av-recording-coords").text(relBoxCoords); 848 936 } 937 938 if ((recAVInside) && (isRecordingUserAV)) { 939 //var xy_rec = av_to_canvas_xy(recValenceVal,recArousalVal, circ_x_org,circ_y_org, circ_radius); 940 //var canvas_x = xy_rec.canvasX; 941 //var canvas_y = xy_rec.canvasY; 942 943 var canvas_x = event.pageX - $(this).offset().left; 944 var canvas_y = event.pageY - $(this).offset().top; 945 946 console.log("canvas x,y = " + canvas_x + " , " + canvas_y); 947 948 var av_canvas = document.getElementById("av-chart-canvas-unlabeled"); 949 var av_context = av_canvas.getContext("2d"); 950 951 av_context.fillStyle = "rgba(190,0,0,0.1)"; 952 //av_context.fillStyle = "rgba(130,0,0,0.1)"; 953 //av_context.fillStyle = "rgba(78,196,108,0.1)"; 954 av_context.beginPath(); 955 av_context.arc(canvas_x, canvas_y, 5, 0, 2 * Math.PI); 956 av_context.fill(); 957 } 849 958 850 959 if (recAVInside != prevRecAVInside) { 851 960 if (recAVInside) { 852 961 // crosshairs on 853 //$('#av-chart-img-unlabeled').css("cursor","crosshair"); 854 var crosshair_record_url = gs.variables.collImagesURL + "/font_awesome--crosshair-red32.png"; 855 //console.log("crosshair_record_url = " + crosshair_record_url); 856 //console.log("url('"+crosshair_record_url+"') 16 16, crosshair"); 857 962 var crosshair_record_url = gs.variables.collImagesURL + "/crosshair-cursor-red32.png"; 858 963 $('#av-chart-img-unlabeled').css("cursor","url('"+crosshair_record_url+"') 16 16, crosshair"); 859 964 }
Note:
See TracChangeset
for help on using the changeset viewer.