ricohapi / theta-client

A library to control RICOH THETA
MIT License
15 stars 11 forks source link

Preview Client Issue #58

Closed dhivya29 closed 6 months ago

dhivya29 commented 8 months ago

@yohei @japboy @togacy @mhirose override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, ): View { _binding = FragmentThetaCameraBinding.inflate(inflater, container, false) return binding.root }

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    lifecycleScope.launch {

        val thetaUrl = "https://fake-theta.vercel.app/"
        val thetaConfig = ThetaRepository.Config()
        thetaConfig.language = ThetaRepository.LanguageEnum.EN_US
        thetaConfig.shutterVolume = 40 // 0 to 100
        thetaConfig.sleepDelay = ThetaRepository.SleepDelayEnum.SLEEP_DELAY_5M
        thetaConfig.offDelay = ThetaRepository.OffDelayEnum.DISABLE
        thetaRepository = newInstance(thetaUrl, thetaConfig)
        thetaRepository?.getOptions(
            listOf(
                ThetaRepository.OptionNameEnum.CameraMode,
                ThetaRepository.OptionNameEnum.PreviewFormat,
                ThetaRepository.OptionNameEnum.CameraControlSource,
                ThetaRepository.OptionNameEnum.CaptureMode
            )
        )?.let { thetaRepository?.setOptions(it)

        }
    }

     startPreview()
}

private fun startPreview() { lifecycleScope.launch { try { thetaRepository?.getLivePreview()?.collect { byteReadPacket ->

                   if (isActive) {
                       byteReadPacket.inputStream().use {
                           val bitmap = BitmapFactory.decodeStream(byteReadPacket.inputStream())

/ Glide.with(requireContext()) // .load(bitmap) // .into(binding.imgTheta) byteReadPacket.release() } } else { Log.e("ThetaCameraFragment", "FALSE")

                   }
               }
           } catch (e: Exception) {
               Log.e("ThetaCameraFragment", "Error during live preview: ${e.message}", e)
               // Handle the error as needed
           }
       }
   }

With this code preview client is not worked Kindly let me know the process of initializing preview Client

simago commented 8 months ago

@dhivya29 You use fake theta. Its protocol is https but theta client preview function does not support https.

dhivya29 commented 8 months ago

@dhivya29 You use fake theta. Its protocol is https but theta client preview function does not support https.

When i use real ip address of the device with theta client means it will work or not? I have downloaded demo app too and in that also preview is not working why?

simago commented 8 months ago

@dhivya29 When using real Theta, preview of the demo should work. In the next release, Android demo will be improved a little. Please try it.

codetricity commented 8 months ago

@dhivya29 I tested theta-client with the SC2 and it works on Android native.

https://youtu.be/shg2kX7Q8pM?si=QwM1gH0puKv0GjkM

What RICOH THETA model are you using?

Note that I don't work for RICOH.