Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Itunes plugin running on device error. Can't play songs in user's apple music library
Started by JustAGuy1 Jun 07 2019 04:32 PM

No replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

JustAGuy1

[GLOBAL: userInfoPane.html]
JustAGuy1
  • Observer

  • 22 posts
  • Corona SDK

I used the Itunes pulgin : https://marketplace.coronalabs.com/corona-plugins/itunes

and successfully built and ran on device (iPad). A panel showed up for picking the songs in my apple music library. I picked a song from the list to play and it showed the error below in the simulator. I am sure that I already downloaded the all songs on my iPad (able to play offline). Here's the error:

*** Terminating app due to uncaught exception 'Corona Runtime Error', reason: '/var/mobile/Containers/Data/Application/67F71AC0-7859-4BBE-A1C9-09827CCA1120/Documents/.CoronaLive/main.lua:85: attempt to index field '?' (a nil value)'

I used exactly the code in the document. No change at all:

local iTunes = require( "plugin.iTunes" )

 
--Table to store media items
local mediaItems = {}
 
-- Function that is executed when song playback is complete
local function onPlaybackEnded()
    print( "Playback completed!" )
end
 
-- Function that is executed after media item(s) have been chosen
local function onMediaChosen( event )
 
    if ( event.data ) then
        for i=1,#event.data do
            mediaItems[i] = event.data[i]
        end
         
        --play the first item chosen
        iTunes.play( mediaItems[1].url, onPlaybackEnded ) --------  line 85 -> error right here , I guess url is nil
 
    end
end
 
local iTunesOptions =
{
    allowsPickingMultipleItems = true,
    promptTitle = "Select some songs"
}
iTunes.show( iTunesOptions, onMediaChosen )

I think the error is at this line with the url property being nil:

iTunes.play( mediaItems[1].url, onPlaybackEnded ) --------  line 85 -> error right here , I guess url is nil

I also tried to code in XCode, using Music Kit, and the URL retrieved from MPMediaItem is also nil. I can print out the song name, artist but the url and lyrics are nil. 

 

Do you have any suggestion? I want to play the songs and print out lyrics. Thank you.




[topic_controls]
[/topic_controls]