예제 #1
0
        /// <summary>
        /// Converts playlist URLs to UTF8 and sets it to use for the playlist in the MusicService.
        /// </summary>
        /// <param name="playlist">The array of URLs</param>
        /// <param name="size">The size of the playList array</param>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful.
        /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to invalid input parameter.
        /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing.
        /// MLResult.Result will be <c>MLResult.Code.MediaGenericNoInit</c> if not connected.
        /// </returns>
        public static MLResult.Code SetPlayListHelper(string[] playlist, ulong size)
        {
            try
            {
                IntPtr[] intPtrList = new IntPtr[playlist.Length];
                for (int i = 0; i < playlist.Length; ++i)
                {
                    intPtrList[i] = MLConvert.EncodeToUnmanagedUTF8(playlist[i]);
                }

                MLResult.Code resultCode = MLMusicServiceNativeBindings.MLMusicServiceSetPlayList(intPtrList, size);

                for (int i = 0; i < intPtrList.Length; ++i)
                {
                    Marshal.FreeHGlobal(intPtrList[i]);
                }

                return(resultCode);
            }
            catch (System.EntryPointNotFoundException)
            {
                MLPluginLog.Error("MLMusicServiceNativeBindings.SetPlayListHelper failed. Reason: API symbols not found");
                return(MLResult.Code.UnspecifiedFailure);
            }
        }
예제 #2
0
 /// <summary>
 /// Converts URL string to UTF8 and sets it for the MusicService.
 /// </summary>
 /// <param name="url">The URL to play</param>
 /// <returns>
 /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful.
 /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to invalid input parameter.
 /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing.
 /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error.
 /// MLResult.Result will be <c>MLResult.Code.MediaGenericNoInit</c> if not connected.
 /// </returns>
 public static MLResult.Code SetURLHelper(string url)
 {
     try
     {
         IntPtr        urlPtr     = MLConvert.EncodeToUnmanagedUTF8(url);
         MLResult.Code resultCode = MLMusicServiceNativeBindings.MLMusicServiceSetURL(urlPtr);
         Marshal.FreeHGlobal(urlPtr);
         return(resultCode);
     }
     catch (System.EntryPointNotFoundException)
     {
         MLPluginLog.Error("MLMusicServiceNativeBindings.SetURLHelper failed. Reason: API symbols not found");
         return(MLResult.Code.UnspecifiedFailure);
     }
 }