0

I have created simple audio apk. In this apk, I have added one option called "choose images" for the Play button in this option. I have an issue that chosen images from the gallery is not showing in the Play button. I have tried this code which is from the phonegap doc. But its not working for me. Below is the code for your reference, wherein I have selected the images.

May I know how to solve this solution. It will be very helpful to me.

<input id="mainplay" data-button="play" type="image" src="img/newplay.png" class="audiodata" id="imgData" alt="Submit" width="70" height="70" />        
             </div>



  function getPhoto(source) {
      // Retrieve image file location from specified source
      navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
        destinationType: destinationType.FILE_URI,
        sourceType: source });
    }
    function onPhotoURISuccess(imageURI) {       


    var largeImage = document.getElementById('largeImage');


      largeImage.style.display = 'block';
      localStorage.setItem("imgData", imageURI);

      $('#imgData').attr('src', imageURI);  
      largeImage.src ="data:image/jpeg;base64," + imageURI;
    } 
<div data-role="page" id="home">            
            <div class="ui-btn-right">              
                <a class="alignment ui-btn-active ui-state-persist" data-role="button" data-icon="gear" data-iconpos="notext"></a>
            </div>  
                <div id="settings" style="display:none;">   
                        <a href="#home" data-inline="true" data-icon="back" data-role="button" class="settings alignment"  data-theme="e" data-iconpos="notext">Back</a><br><br>
                        <fieldset class="ui-field-contain">
                            <label for="Choose Audio">Choose Audio</label>
                            <select class="audioselect" name="selectaudio" id="selectaudio"> 
                              <option value="/android_asset/www/audio/Commercial DEMO - 15.mp3">Commercial DEMO</option><option  value="/android_asset/www/audio/p1rj1s_-_rockGuitar.mp3">RockGuitar</option> 
                            </select>
                        </fieldset><br>
                            <fieldset class="ui-field-contain">
                                <label for="Volume">Volume Control</label><br>
                                <span class="tooltip"></span> <!-- Tooltip -->
                                <div id="slider"></div> <!-- the Slider -->
                                <span class="volume"></span> <!-- Volume -->        
                            </fieldset><br>
                            <fieldset>
                    <button data-inline="true" onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">Choose Photos</button>
                        <div style="display:none;"><img id="largeImage" src="" /></div>     </fieldset><br>
                    </div>  
                <input id="mainplay" data-button="play" type="image" src="img/newplay.png" class="audiodata" id="imgData" alt="Submit" width="70" height="70" />        
         </div>
Sri
  • 631
  • 2
  • 7
  • 21
  • What version of cordova are you using? any console errors?.. – Aravin Sep 30 '14 at 08:00
  • cordova 3.5.1 version – Sri Sep 30 '14 at 11:27
  • are you added the require plugin.. – Aravin Sep 30 '14 at 13:27
  • yes I have added the required plugin camera and media plugin through cmd my problem in here is the function is choosing the picture in frontend but it does not go into onPhotoURISuccess function thats the problem I don't know why its going into that function? – Sri Oct 01 '14 at 14:16
  • Try with lower versions..because last week one of my friend found issue in contact api in 3.5.1 now cordova community resolved the issue..Your code seems okay... – Aravin Oct 01 '14 at 17:07

1 Answers1

0
  • I don't see a reference to phonegap.js in your code.
  • You don't have a script tag around your JavaScript code.
  • You need an ondeviceready function and add these two lines of code;

    pictureSource=navigator.camera.PictureSourceType; destinationType=navigator.camera.DestinationType;

Please read further on here and study the full example carefully.

Emre
  • 159
  • 11
  • while building the phonegap.js will automatically included in this path D:\mobileapps\finalaudio\platforms\android\assets\www and I didn't paste the entire code here I just show where my code has been stucked – Sri Oct 02 '14 at 12:36