Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-24486

iOS: How to stringify a mediaItem properly.

    Details

    • Type: Story
    • Status: Closed
    • Priority: None
    • Resolution: Duplicate
    • Affects Version/s: Release 6.0.2
    • Fix Version/s: None
    • Component/s: None
    • Environment:

      Description

      description

      Experiencing the JSON.stringify on a media item returns "{}" instead of a real stringified output that I can parse.

      app.js

       
      var win = Ti.UI.createWindow({
      		backgroundColor : '#fff'
      	});
       
      	var btn = Ti.UI.createButton({
      		title : 'Trigger'
      	});
       
      	btn.addEventListener('click', function() {
      		Titanium.Media.openMusicLibrary({
      			allowMultipleSelections : false,
      			mediaTypes : Titanium.Media.MUSIC_MEDIA_TYPE_MUSIC | Titanium.Media.MUSIC_MEDIA_TYPE_ANY_AUDIO,
      			success : function(event) {
      				// called when media returned from the MusicLibrary
      				alert("Results: " + JSON.stringify(event.items[0]));
      			},
      			cancel : function() {
      				alert("Aborting ");
      			},
      			error : function(error) {
      				// called when there's an error
      				var a = Titanium.UI.createAlertDialog({
      					title : 'Music Library'
      				});
      				if (error.code == Titanium.Media.NO_MUSIC_PLAYER) {
      					a.setMessage('Please run this test on device.');
      				} else {
      					a.setMessage('Unexpected error: ' + error.code);
      				}
      				a.show();
      			}
      		});
       
      	});
       
      	win.add(btn);
       
       win.open();
      
      

      Thanks

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hknoechel Hans Knöchel
                Reporter:
                morahman Motiur Rahman
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-10548
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration